|
| 1 | +name: Code Quality Checks |
| 2 | + |
| 3 | +permissions: |
| 4 | + contents: write |
| 5 | + pull-requests: write |
| 6 | + |
| 7 | +on: |
| 8 | + pull_request: |
| 9 | + types: [opened, synchronize, reopened] |
| 10 | + |
| 11 | + workflow_dispatch: |
| 12 | + |
| 13 | +# Cancel in-progress jobs when a new push is made to the same PR |
| 14 | +concurrency: |
| 15 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 16 | + cancel-in-progress: true |
| 17 | + |
| 18 | +jobs: |
| 19 | + main-checks: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + steps: |
| 22 | + - name: Check out Git repository |
| 23 | + uses: actions/checkout@v4 |
| 24 | + |
| 25 | + - name: Install Node.js |
| 26 | + uses: actions/setup-node@v4 |
| 27 | + with: |
| 28 | + node-version: 22 |
| 29 | + |
| 30 | + - name: Setup Bun |
| 31 | + uses: oven-sh/setup-bun@v2 |
| 32 | + with: |
| 33 | + bun-version: latest |
| 34 | + |
| 35 | + - name: Install Dependencies |
| 36 | + run: bun install --development --frozen-lockfile |
| 37 | + |
| 38 | + - name: Run Type Check |
| 39 | + run: bun run typecheck |
| 40 | + |
| 41 | + - name: Run Lint |
| 42 | + run: bun run lint |
| 43 | + |
| 44 | + format: |
| 45 | + runs-on: ubuntu-latest |
| 46 | + steps: |
| 47 | + - name: Check out Git repository |
| 48 | + uses: actions/checkout@v4 |
| 49 | + with: |
| 50 | + ref: ${{ github.head_ref }} |
| 51 | + |
| 52 | + - name: Install Node.js |
| 53 | + uses: actions/setup-node@v4 |
| 54 | + with: |
| 55 | + node-version: 22 |
| 56 | + |
| 57 | + - name: Setup Bun |
| 58 | + uses: oven-sh/setup-bun@v2 |
| 59 | + with: |
| 60 | + bun-version: latest |
| 61 | + |
| 62 | + - name: Install Dependencies |
| 63 | + run: bun install --development --frozen-lockfile |
| 64 | + |
| 65 | + - name: Format Code |
| 66 | + run: bun run format |
| 67 | + |
| 68 | + - name: Check for changes |
| 69 | + id: git-check |
| 70 | + run: | |
| 71 | + git diff --exit-code || echo "changes=true" >> $GITHUB_OUTPUT |
| 72 | +
|
| 73 | + - name: Commit changes if any |
| 74 | + if: steps.git-check.outputs.changes == 'true' |
| 75 | + run: | |
| 76 | + git config --local user.email "[email protected]" |
| 77 | + git config --local user.name "github-actions" |
| 78 | + git commit -am "style: format code with prettier" |
| 79 | + git push |
0 commit comments