-
Notifications
You must be signed in to change notification settings - Fork 28
51 lines (42 loc) · 1.41 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run type check
run: npm run typecheck
- name: Format code
run: npm run format
# For pushes to main or PRs from same repo, commit formatting changes
- name: Commit changes
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "style: format code with prettier"
branch: ${{ github.event_name == 'push' && 'main' || github.head_ref }}
# For PRs from forks, fail the check if there are formatting changes required
- name: Check for uncommitted changes
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository
run: |
if [[ -n "$(git status --porcelain)" ]]; then
echo "::error::Code formatting issues found. Please run 'npm run format' locally and commit the changes."
git diff
exit 1
fi