|
| 1 | +# Runs the dispatch GATE for AI code reviews on this repo's PRs. |
| 2 | +# Forwards to the shared decider workflow in nsheaps/agents, which evaluates |
| 3 | +# whether to dispatch a review and (if yes) fires a repository_dispatch to the |
| 4 | +# target agent repo's dispatch-receiver-review.yaml. |
| 5 | +# |
| 6 | +# This file is a template — copy into your repo at |
| 7 | +# `.github/workflows/dispatch-review.yaml`. Synced via `nsheaps/.github` CI |
| 8 | +# automation when configured; until then, copy-paste. |
| 9 | +# |
| 10 | +# Spec: https://github.com/nsheaps/agents/blob/main/plugins/claude-code/review-utils/specs/review-dispatch.md |
| 11 | +# |
| 12 | +# Requirements (provisioned via nsheaps/.github/secret-sync.yaml): |
| 13 | +# - AUTOMATION_GITHUB_APP_ID |
| 14 | +# - AUTOMATION_GITHUB_APP_PRIVATE_KEY (automation-nsheaps[bot]; installed on |
| 15 | +# THIS repo for label edit + check_run |
| 16 | +# posting, AND on the target agent repo |
| 17 | +# so it can fire repository_dispatch) |
| 18 | +# |
| 19 | +# Why automation creds (not REVIEW_GITHUB_APP_*)? The gate is routing only — |
| 20 | +# it never speaks AS the reviewer. It edits a label, posts a queued check, and |
| 21 | +# fires a repository_dispatch. The reviewer-identity (REVIEW_GITHUB_APP_*) is |
| 22 | +# owned by the target agent's `dispatch-receiver-review.yaml`, where the review |
| 23 | +# actually executes. See plugins/claude-code/review-utils/specs/review-dispatch.md |
| 24 | +# §Secrets for the gate-vs-receiver creds rationale. |
| 25 | +# |
| 26 | +# LLM-auth secrets (REVIEW_ANTHROPIC_API_KEY / CLAUDE_CODE_OAUTH_TOKEN) are |
| 27 | +# NOT needed here — owned by the target agent's receiver for the same reason. |
| 28 | + |
| 29 | +name: Dispatch PR Review |
| 30 | + |
| 31 | +on: |
| 32 | + pull_request: |
| 33 | + types: [opened, reopened, synchronize, ready_for_review, labeled] |
| 34 | + |
| 35 | +# Explicit top-level permissions (mirrors the job-level grant below) so |
| 36 | +# checkov's CKV2_GHA_1 ("top-level permissions not write-all") is satisfied. |
| 37 | +permissions: |
| 38 | + contents: read |
| 39 | + pull-requests: write |
| 40 | + checks: write |
| 41 | + |
| 42 | +jobs: |
| 43 | + review: |
| 44 | + # Gate: review fires automatically on any OPEN, non-draft PR event |
| 45 | + # (opened, reopened, synchronize, ready_for_review) -- no label needed. |
| 46 | + # The `request-review` label only matters to FORCE a review on a DRAFT |
| 47 | + # PR (apply the label while it's still a draft). `converted_to_draft` |
| 48 | + # does NOT fire a review by itself -- a PR converted to draft is simply |
| 49 | + # not reviewed until it's marked ready again or explicitly labeled. If |
| 50 | + # you change the request label name, update the literal in the `==` |
| 51 | + # comparison below. |
| 52 | + if: | |
| 53 | + github.event.pull_request.state == 'open' && |
| 54 | + ( |
| 55 | + github.event.pull_request.draft != true || |
| 56 | + (github.event.action == 'labeled' && github.event.label.name == 'request-review') |
| 57 | + ) |
| 58 | + # Explicit permissions: default_workflow_permissions is "read" in many |
| 59 | + # repos but the called workflow needs pull-requests + checks write. |
| 60 | + permissions: |
| 61 | + contents: read |
| 62 | + pull-requests: write |
| 63 | + checks: write |
| 64 | + # @main = rolling updates: any change merged to nsheaps/agents takes effect |
| 65 | + # on the next PR event in repos using this template. This is intentional — |
| 66 | + # operators who need pinned stability should replace @main with a commit SHA |
| 67 | + # and update it in lock-step with plugin version bumps. |
| 68 | + uses: nsheaps/agents/.github/workflows/review-dispatch.yaml@9384e01dd798d677750775d50068853aeb315b0b # main |
| 69 | + # secrets: inherit doesn't pass cross-repo (GitHub limitation). |
| 70 | + secrets: |
| 71 | + AUTOMATION_GITHUB_APP_ID: ${{ secrets.AUTOMATION_GITHUB_APP_ID }} |
| 72 | + AUTOMATION_GITHUB_APP_PRIVATE_KEY: ${{ secrets.AUTOMATION_GITHUB_APP_PRIVATE_KEY }} |
| 73 | + # Optional overrides (uncomment to use): |
| 74 | + # with: |
| 75 | + # target-repo: nsheaps/.ai-agent-henry # default |
| 76 | + # event-type: pr-review # default repository_dispatch event_type |
0 commit comments