Skip to content

Commit e1e7f01

Browse files
committed
ci: Restrict who can run Claude workflows
Use guardrails to restrict who can run Claude-related workflows. - For code reviews, only run the workflow if the author of the Pull Request is from the owning organisation, or the owner, or a GitHub collaborator for the repository. - For @claude comments in Issue comments and descriptions or Pull Request review comments, restrict the workflow to commenters with the same association (member, owner, or collaborator). Link: https://docs.github.com/en/graphql/reference/enums#commentauthorassociation Link: https://docs.github.com/en/webhooks/webhook-events-and-payloads Signed-off-by: Quentin Monnet <[email protected]>
1 parent c33d8ab commit e1e7f01

File tree

2 files changed

+36
-9
lines changed

2 files changed

+36
-9
lines changed

.github/workflows/claude-code-review.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@ on:
1212

1313
jobs:
1414
claude-review:
15-
# Optional: Filter by PR author
16-
# if: |
17-
# github.event.pull_request.user.login == 'external-contributor' ||
18-
# github.event.pull_request.user.login == 'new-developer' ||
19-
# github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'
15+
# Filter by Pull Request author:
16+
# - MEMBER: Author is a member of the organization that owns the repository.
17+
# - OWNER: Author is the owner of the repository.
18+
# - COLLABORATOR: Author has been invited to collaborate on the repository.
19+
if: |
20+
github.event.pull_request.author_association == 'MEMBER' ||
21+
github.event.pull_request.author_association == 'OWNER' ||
22+
github.event.pull_request.author_association == 'COLLABORATOR'
2023
2124
runs-on: ubuntu-latest
2225
permissions:

.github/workflows/claude-conversations.yml

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,35 @@ on:
1212

1313
jobs:
1414
claude:
15+
# Filter by comment/review/issue author:
16+
# - MEMBER: Author is a member of the organization that owns the repository.
17+
# - OWNER: Author is the owner of the repository.
18+
# - COLLABORATOR: Author has been invited to collaborate on the repository.
1519
if: |
16-
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
17-
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
18-
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
19-
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
20+
(github.event_name == 'issue_comment' &&
21+
(github.event.comment.author_association == 'MEMBER' ||
22+
github.event.comment.author_association == 'OWNER' ||
23+
github.event.comment.author_association == 'COLLABORATOR') &&
24+
contains(github.event.comment.body, '@claude')) ||
25+
26+
(github.event_name == 'pull_request_review_comment' &&
27+
(github.event.comment.author_association == 'MEMBER' ||
28+
github.event.comment.author_association == 'OWNER' ||
29+
github.event.comment.author_association == 'COLLABORATOR') &&
30+
contains(github.event.comment.body, '@claude')) ||
31+
32+
(github.event_name == 'pull_request_review' &&
33+
(github.event.review.author_association == 'MEMBER' ||
34+
github.event.review.author_association == 'OWNER' ||
35+
github.event.review.author_association == 'COLLABORATOR') &&
36+
contains(github.event.review.body, '@claude')) ||
37+
38+
(github.event_name == 'issues' &&
39+
(github.event.issue.author_association == 'MEMBER' ||
40+
github.event.issue.author_association == 'OWNER' ||
41+
github.event.issue.author_association == 'COLLABORATOR') &&
42+
(contains(github.event.issue.body, '@claude') ||
43+
contains(github.event.issue.title, '@claude')))
2044
runs-on: ubuntu-latest
2145
permissions:
2246
contents: read

0 commit comments

Comments
 (0)