name: Quality Decision on: pull_request_target: types: [opened, reopened, synchronize] workflow_run: workflows: [Change Quality] types: [in_progress, completed] permissions: contents: read actions: write pull-requests: write statuses: write jobs: resolve: runs-on: ubuntu-latest permissions: {} outputs: pr: ${{ steps.pr.outputs.pr }} queue: ${{ steps.pr.outputs.queue }} steps: - id: pr run: | node <<'JS' const fs = require('node:fs'); const event = JSON.parse(fs.readFileSync(process.env.GITHUB_EVENT_PATH, 'utf8')); const run = event.workflow_run; if (run?.event === 'merge_group' && run.status === 'completed') { fs.appendFileSync(process.env.GITHUB_OUTPUT, `queue=${run.id}\n`); } const match = run?.event === 'issue_comment' && /^Quality PR #(\d+) request \d+$/.exec(run.display_title); const pr = event.pull_request?.number ?? (match ? Number(match[1]) : undefined); if (Number.isSafeInteger(pr) && pr > 0) fs.appendFileSync(process.env.GITHUB_OUTPUT, `pr=${pr}\n`); JS publish: needs: [resolve] if: needs.resolve.outputs.pr != '' concurrency: group: quality-decision-${{ needs.resolve.outputs.pr }} cancel-in-progress: false queue: max name: Publish quality decision runs-on: ubuntu-latest timeout-minutes: 5 steps: # Never check out or run PR code in this privileged job. It downloads only the small # findings file, which comment.mts validates and escapes; it never opens the full reports. - uses: actions/checkout@v5 with: ref: ${{ github.workflow_sha }} persist-credentials: false sparse-checkout: scripts/quality - uses: actions/setup-node@v5 with: node-version: '24.22.3' # A `name` that matches no artifact fails the step. The comment must still update, and # comment.mts reports the missing file, so this step continues on error. - name: Download report findings if: github.event_name == 'workflow_run' && github.event.workflow_run.status == 'completed' continue-on-error: true uses: actions/download-artifact@v6 with: name: quality-internal-findings run-id: ${{ github.event.workflow_run.id }} github-token: ${{ github.token }} path: findings - env: GH_TOKEN: ${{ github.token }} QUALITY_REFACTOR_HINTS: ${{ vars.QUALITY_REFACTOR_HINTS }} QUALITY_CRAP_THRESHOLD: ${{ vars.QUALITY_CRAP_THRESHOLD }} run: node scripts/quality/comment.mts publish queue: name: Publish queue quality decision needs: [resolve] if: needs.resolve.outputs.queue != '' runs-on: ubuntu-latest timeout-minutes: 5 permissions: contents: read pull-requests: read actions: read statuses: write concurrency: group: quality-queue-${{ github.event.workflow_run.head_sha }} cancel-in-progress: false steps: - uses: actions/checkout@v5 with: ref: ${{ github.workflow_sha }} persist-credentials: false sparse-checkout: scripts/quality - uses: actions/setup-node@v5 with: node-version: '24.22.1' - env: GH_TOKEN: ${{ github.token }} run: node scripts/quality/queue.mts