ci: gate claude.yml on author_association to skip unauthorized invokes#1268
Closed
cliffhall wants to merge 1 commit into
Closed
ci: gate claude.yml on author_association to skip unauthorized invokes#1268cliffhall wants to merge 1 commit into
cliffhall wants to merge 1 commit into
Conversation
Previously the workflow's `if:` only checked the event type and the presence of `@claude` in the body. The job would start for any commenter and only later fail when the action attempted privileged operations on behalf of a user without write access. That produced noisy red runs and wasted runner minutes for what is effectively an authorization rejection. Add an `author_association` check (OWNER, MEMBER, or COLLABORATOR) to each of the four trigger branches (issue_comment, pull_request_review_comment, pull_request_review, issues), so the job is short-circuited at workflow evaluation time and never starts for unauthorized invokers. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Member
Author
|
@claude review |
Contributor
|
I'll analyze this and get back to you. |
Member
Author
|
Closing in favor of a same-repo PR — the cross-repo fork variant trips a known fork-PR checkout path in claude-code-action that prevents |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Tighten the trigger conditions for
.github/workflows/claude.ymlso the job is skipped at workflow evaluation time when the invoking user does not have write access, rather than starting and later failing when the action tries to perform privileged operations.Background
We observed a case where someone left an
@claudecomment on a PR and the workflow started running, then errored out partway through because the commenter didn't have the repo permissions Claude needs to act on their behalf. That's the intended security posture (only trusted users should be able to drive Claude in this repo), but the failure mode wasn't great:Change
Add an
author_associationcheck to each of the four trigger branches (issue_comment,pull_request_review_comment,pull_request_review,issues). The job'sif:now requires the author to beOWNER,MEMBER, orCOLLABORATORin addition to the existing event-type and@claudebody checks.author_associationis supplied by GitHub on the event payload itself, so this check happens during workflow evaluation — before a runner is allocated. Comments from users without write access become silent no-ops instead of failed runs.This doesn't change who is allowed to drive Claude (the action itself already enforces this); it just moves the rejection earlier in the pipeline and makes it quiet.
Test plan
@claude ...from an account with write access on an issue or PR — workflow runs as before.@claude ...from an account without write access — workflow is skipped (no run appears in Actions), instead of starting and failing.issue_comment,pull_request_review_comment,pull_request_review,issues) behave consistently.🤖 Generated with Claude Code