|
| 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, converted_to_draft] |
| 34 | + |
| 35 | +jobs: |
| 36 | + review: |
| 37 | + # Gate at the template level (post-2026-05-23 redesign): only dispatch |
| 38 | + # when the PR is open AND carries the request-review label. The |
| 39 | + # `converted_to_draft` event also fires (PR is still in state=open while |
| 40 | + # draft) so the receiver can short-circuit with a `neutral` check rather |
| 41 | + # than running a review on a drafted PR. If you change the request label |
| 42 | + # name, update the literal in the `contains(...)` expression below. |
| 43 | + if: | |
| 44 | + github.event.pull_request.state == 'open' && |
| 45 | + contains(github.event.pull_request.labels.*.name, 'request-review') |
| 46 | + # Explicit permissions: default_workflow_permissions is "read" in many |
| 47 | + # repos but the called workflow needs pull-requests + checks write. |
| 48 | + permissions: |
| 49 | + contents: read |
| 50 | + pull-requests: write |
| 51 | + checks: write |
| 52 | + # @main = rolling updates: any change merged to nsheaps/agents takes effect |
| 53 | + # on the next PR event in repos using this template. This is intentional — |
| 54 | + # operators who need pinned stability should replace @main with a commit SHA |
| 55 | + # and update it in lock-step with plugin version bumps. |
| 56 | + uses: nsheaps/agents/.github/workflows/review-dispatch.yaml@main |
| 57 | + # secrets: inherit doesn't pass cross-repo (GitHub limitation). |
| 58 | + secrets: |
| 59 | + AUTOMATION_GITHUB_APP_ID: ${{ secrets.AUTOMATION_GITHUB_APP_ID }} |
| 60 | + AUTOMATION_GITHUB_APP_PRIVATE_KEY: ${{ secrets.AUTOMATION_GITHUB_APP_PRIVATE_KEY }} |
| 61 | + # Optional overrides (uncomment to use): |
| 62 | + # with: |
| 63 | + # target-repo: nsheaps/.ai-agent-henry # default |
| 64 | + # event-type: pr-review # default repository_dispatch event_type |
0 commit comments