claude-code-review: allow the github-actions bot to dispatch reviews#36
Conversation
claude.yml re-dispatches the review workflow after an @claude run pushes commits, via `gh workflow run` (which runs as github-actions[bot]). But claude-code-action's agent mode — what workflow_dispatch uses — blocks bot actors by default and fails the run with "Workflow initiated by non-human actor". Because the dispatched run still enters the per-PR concurrency group first, it cancels the parallel `synchronize` auto-review on its way out, so a push that triggers both ends up with no review at all (observed on #34). Set `allowed_bots: github-actions[bot]` on the review action so the dispatched review can actually run. Scoped to the one bot that legitimately dispatches us; the job `if:` already filters bot actors out of the automatic pull_request path, and the dispatch path is only reachable via claude.yml's trusted-author gate (or a manual dispatch needing write access). Also correct the now-misleading "Review canceled" note and the concurrency comment, which blamed cancellations solely on a newer commit: a re-dispatched review of the same PR supersedes a running one too. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XcWt36sA6nvWWZkvFqTc53
This comment has been minimized.
This comment has been minimized.
The "Collapse previous Claude review comments" step was gated to github.event_name == 'pull_request'. Now that the allowed_bots fix lets a workflow_dispatch review actually succeed, a dispatched run that wins the per-PR concurrency race would post its review but leave earlier pushes' review comments expanded, because the collapse step skipped non-pull_request events. Drop the event gate (keep the success gate). The run_id->workflow-path match already scopes the fold to this workflow's own comments, so it's safe on dispatched runs. The cancel-fold step stays pull_request-only: agent mode creates no tracking comment, so a cancelled dispatch has nothing to fold. Addresses the pre-existing gap surfaced in the PR #36 review. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XcWt36sA6nvWWZkvFqTc53
|
Claude finished @d-morrison's task in 3m 8s —— View job Code Review — PR #36
Verdict: LGTM. Both changes are correctly targeted, minimal in scope, and well-documented.
|
Why
On #34, the latest push got no review. Root cause, traced through the run logs:
@claude"Address PR Add reusable PR-preview/publish workflow family #34 review" commit) triggered two reviews in the same concurrency groupclaude-review-34:pull_request/synchronizereview (run #84), andclaude.yml's explicitworkflow_dispatchre-dispatch (run #85), kicked off bygh workflow runasgithub-actions[bot].cancel-in-progress: true, so run #85 entering the group cancelled the in-progress run #84 (which had been doing the actual review).claude-code-action's agent mode (whichworkflow_dispatchuses, sincetrack_progressisfalsefor dispatched runs) blocks bot actors by default, andclaude-code-review.ymlnever setallowed_bots. So every bot-dispatched review failed this gate — and on the way out, cancelled the parallel auto-review. Net: no review on the push.What
allowed_bots: 'github-actions[bot]'on theRun Claude Code Reviewstep. This is the input the error message points at; the matcher lowercases and strips[bot]from both sides, so this value matches thegithub-actions[bot]dispatcher. Scoped to the one bot that legitimately dispatches us — the jobif:already filters bot actors out of the automaticpull_requestpath, and the dispatch path is only reachable viaclaude.yml's trusted-author gate (or a manual dispatch needing write access).With
allowed_botsin place, a push that fires both triggers resolves cleanly: the later run posts the current review and the collapse/cancel steps fold the other as OUTDATED — one visible review per push.Scope note
I deliberately did not try to suppress the double-trigger itself. The unconditional re-dispatch in
claude.ymlis intentional belt-and-suspenders: aGITHUB_TOKENpush (or a GitHub-App-token push) fires no usablesynchronize, so the dispatch is the only review path in those cases.claude.ymlcan't reliably tell which token/sender produced the push, so suppressing the dispatch would risk dropping reviews entirely. Once the dispatched run can run (this PR), the existing per-PR concurrency dedupe does the right thing.Testing
claude-code-review.ymlisn't in_selftest.yml(it needs a live PR + the OAuth token) and this repo dogfoods it via@v1, so the change takes effect for this repo only oncev1is moved. YAML validated locally; edits are limited to one new input, comments, a message string, and the CHANGELOG.🤖 Generated with Claude Code
Generated by Claude Code