ci: gate claude.yml on author_association to skip unauthorized invokes
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>
This commit is contained in:
parent
adfcccca52
commit
c044b5d65f
1 changed files with 20 additions and 4 deletions
24
.github/workflows/claude.yml
vendored
24
.github/workflows/claude.yml
vendored
|
|
@ -14,10 +14,26 @@ jobs:
|
||||||
claude:
|
claude:
|
||||||
if: |
|
if: |
|
||||||
(
|
(
|
||||||
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
|
(github.event_name == 'issue_comment' &&
|
||||||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
|
contains(github.event.comment.body, '@claude') &&
|
||||||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
|
(github.event.comment.author_association == 'OWNER' ||
|
||||||
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
|
github.event.comment.author_association == 'MEMBER' ||
|
||||||
|
github.event.comment.author_association == 'COLLABORATOR')) ||
|
||||||
|
(github.event_name == 'pull_request_review_comment' &&
|
||||||
|
contains(github.event.comment.body, '@claude') &&
|
||||||
|
(github.event.comment.author_association == 'OWNER' ||
|
||||||
|
github.event.comment.author_association == 'MEMBER' ||
|
||||||
|
github.event.comment.author_association == 'COLLABORATOR')) ||
|
||||||
|
(github.event_name == 'pull_request_review' &&
|
||||||
|
contains(github.event.review.body, '@claude') &&
|
||||||
|
(github.event.review.author_association == 'OWNER' ||
|
||||||
|
github.event.review.author_association == 'MEMBER' ||
|
||||||
|
github.event.review.author_association == 'COLLABORATOR')) ||
|
||||||
|
(github.event_name == 'issues' &&
|
||||||
|
(contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')) &&
|
||||||
|
(github.event.issue.author_association == 'OWNER' ||
|
||||||
|
github.event.issue.author_association == 'MEMBER' ||
|
||||||
|
github.event.issue.author_association == 'COLLABORATOR'))
|
||||||
)
|
)
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue