|
| 1 | +# Stage 2 caller for the Claude PR-review integration: the "review" workflow. |
| 2 | +# |
| 3 | +# Triggered by completion of the Stage-1 "collect" workflow. Because the trigger |
| 4 | +# is workflow_run, GitHub runs this file from the default branch (never a fork's |
| 5 | +# copy) and with this repo's secrets -- so a fork PR cannot alter the review |
| 6 | +# behavior, permissions, or credential setup. |
| 7 | +# |
| 8 | +# All the review logic (Bedrock auth, the pinned action, the restricted tool |
| 9 | +# surface, the read-only PR-head checkout, and per-run limits) lives in the |
| 10 | +# reusable workflow in aws-deadline/.github. This caller only forwards the |
| 11 | +# workflow_run identifiers and the role-ARN secret. |
| 12 | +name: Claude PR Review |
| 13 | + |
| 14 | +on: |
| 15 | + workflow_run: |
| 16 | + workflows: ["Claude PR Review (collect)"] |
| 17 | + types: |
| 18 | + - completed |
| 19 | + |
| 20 | +# Cancel a superseded review when the PR is pushed again, keyed on the trusted head repo + branch from the workflow_run payload (no pull_request.number here). |
| 21 | +concurrency: |
| 22 | + group: claude-pr-review-${{ github.event.workflow_run.head_repository.full_name }}-${{ github.event.workflow_run.head_branch }} |
| 23 | + cancel-in-progress: true |
| 24 | + |
| 25 | +# Least privilege. The reusable workflow re-declares the same scopes on its job; |
| 26 | +# these are the ceiling for the called workflow. |
| 27 | +permissions: |
| 28 | + contents: read |
| 29 | + pull-requests: write |
| 30 | + issues: write |
| 31 | + id-token: write |
| 32 | + |
| 33 | +jobs: |
| 34 | + review: |
| 35 | + # Only run if Stage 1 succeeded, and only for runs triggered by a |
| 36 | + # pull_request. The collect workflow listens on pull_request alone today, but |
| 37 | + # gating on the event here is defense in depth: if another trigger |
| 38 | + # (workflow_dispatch, schedule, ...) is ever added to the collect workflow, |
| 39 | + # this prevents a review from firing -- with the base repo's secrets and a |
| 40 | + # fork-controlled head_sha -- from a non-PR context. |
| 41 | + if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request' }} |
| 42 | + uses: aws-deadline/.github/.github/workflows/reusable_claude_pr_review.yml@mainline |
| 43 | + permissions: |
| 44 | + contents: read |
| 45 | + pull-requests: write |
| 46 | + issues: write |
| 47 | + id-token: write |
| 48 | + with: |
| 49 | + # Head repo and head SHA come from the server-populated workflow_run event |
| 50 | + # payload, which a fork cannot forge. The review stage resolves the PR |
| 51 | + # number and base SHA from these, so nothing fork-controlled is trusted. |
| 52 | + head_repository: ${{ github.event.workflow_run.head_repository.full_name }} |
| 53 | + head_sha: ${{ github.event.workflow_run.head_sha }} |
| 54 | + secrets: |
| 55 | + # OIDC role that can mint a Bedrock bearer token. |
| 56 | + bedrock_role_arn: ${{ secrets.AWS_CLAUDE_PR_REVIEW_ROLE }} |
0 commit comments