name: Lint & Prettier on: pull_request: branches: [main, dev] concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: lint: runs-on: ubuntu-24.04 timeout-minutes: 45 permissions: pull-requests: write steps: - uses: actions/checkout@v6 - uses: actions/setup-node@v6 with: node-version-file: .nvmrc - name: Install dependencies run: npm install - name: Run lint & format check # Both are check-only: lint used to run eslint --fix, which rewrote the # files before format:check looked at them, so neither could fail on # formatting. lint:format holds every file outside # scripts/format-baseline.json to Prettier; the list only shrinks. id: checks continue-on-error: true run: | cd shared npm run lint npm run lint:format - name: Comment on PR if checks failed if: steps.checks.outcome == 'failure' uses: actions/github-script@v8 with: script: | await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, body: [ '## ❌ Lint & Prettier check failed', '', 'Please fix the issues locally by running the following commands inside the `shared` package:', '', '```bash', 'cd shared', 'npm run lint:fix', 'npx prettier --write # each file lint:format names', 'npm run lint:format -- --update # when a listed file is formatted now', '```', '', 'Then commit and push the changes.', ].join('\n'), }); - name: Fail the job if checks failed if: steps.checks.outcome == 'failure' run: exit 1