|
18 | 18 | # contents: read # Read repository files and PR diffs |
19 | 19 | # pull-requests: write # Post review comments and approve/request changes |
20 | 20 | # issues: write # Create security incident issues if secrets are detected in output |
| 21 | +# checks: write # (Optional) Show review progress as a check run on the PR |
21 | 22 | # secrets: |
22 | 23 | # ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} |
23 | 24 | # CAGENT_ORG_MEMBERSHIP_TOKEN: ${{ secrets.CAGENT_ORG_MEMBERSHIP_TOKEN }} # PAT with read:org scope; gates auto-reviews to org members only |
@@ -99,6 +100,7 @@ permissions: |
99 | 100 | contents: read |
100 | 101 | pull-requests: write |
101 | 102 | issues: write |
| 103 | + checks: write |
102 | 104 |
|
103 | 105 | jobs: |
104 | 106 | # ========================================================================== |
@@ -203,6 +205,30 @@ jobs: |
203 | 205 | exit-code: ${{ steps.run-review.outputs.exit-code }} |
204 | 206 |
|
205 | 207 | steps: |
| 208 | + - name: Create check run |
| 209 | + id: create-check |
| 210 | + continue-on-error: true # Don't fail if caller didn't grant checks: write |
| 211 | + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 |
| 212 | + env: |
| 213 | + PR_NUMBER: ${{ inputs.pr-number || github.event.issue.number }} |
| 214 | + with: |
| 215 | + script: | |
| 216 | + const prNumber = parseInt(process.env.PR_NUMBER, 10); |
| 217 | + const { data: pr } = await github.rest.pulls.get({ |
| 218 | + owner: context.repo.owner, |
| 219 | + repo: context.repo.repo, |
| 220 | + pull_number: prNumber |
| 221 | + }); |
| 222 | + const { data: check } = await github.rest.checks.create({ |
| 223 | + owner: context.repo.owner, |
| 224 | + repo: context.repo.repo, |
| 225 | + name: 'PR Review', |
| 226 | + head_sha: pr.head.sha, |
| 227 | + status: 'in_progress', |
| 228 | + started_at: new Date().toISOString() |
| 229 | + }); |
| 230 | + core.setOutput('check-id', check.id); |
| 231 | +
|
206 | 232 | # Checkout PR head (not default branch) |
207 | 233 | # Note: Authorization is handled by the composite action's built-in check |
208 | 234 | - name: Checkout PR head |
@@ -240,6 +266,28 @@ jobs: |
240 | 266 | nebius-api-key: ${{ secrets.NEBIUS_API_KEY }} |
241 | 267 | mistral-api-key: ${{ secrets.MISTRAL_API_KEY }} |
242 | 268 |
|
| 269 | + - name: Update check run |
| 270 | + if: always() && steps.create-check.outputs.check-id != '' |
| 271 | + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 |
| 272 | + env: |
| 273 | + CHECK_ID: ${{ steps.create-check.outputs.check-id }} |
| 274 | + JOB_STATUS: ${{ job.status }} |
| 275 | + with: |
| 276 | + script: | |
| 277 | + const conclusion = process.env.JOB_STATUS === 'cancelled' ? 'cancelled' : process.env.JOB_STATUS === 'success' ? 'success' : 'failure'; |
| 278 | + try { |
| 279 | + await github.rest.checks.update({ |
| 280 | + owner: context.repo.owner, |
| 281 | + repo: context.repo.repo, |
| 282 | + check_run_id: parseInt(process.env.CHECK_ID, 10), |
| 283 | + status: 'completed', |
| 284 | + conclusion: conclusion, |
| 285 | + completed_at: new Date().toISOString() |
| 286 | + }); |
| 287 | + } catch (error) { |
| 288 | + core.warning(`Failed to update check run: ${error.message}`); |
| 289 | + } |
| 290 | +
|
243 | 291 | # ========================================================================== |
244 | 292 | # CAPTURE FEEDBACK |
245 | 293 | # Saves feedback data as an artifact for lazy processing. This job |
|
0 commit comments