Skip to content

Commit bce7c46

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. - For @claude comments in Issue comments and descriptions or Pull Request review comments, restrict the workflow to commenters from the owning organisation. These checks could be extended with COLLABORATOR in addition to MEMBER in the future, depending on our needs. 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 <qmo@qmon.net>
1 parent c33d8ab commit bce7c46

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ 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+
if: |
18+
github.event.pull_request.author_association == 'MEMBER'
2019
2120
runs-on: ubuntu-latest
2221
permissions:

.github/workflows/claude-conversations.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,25 @@ 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.
1517
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')))
18+
(github.event_name == 'issue_comment' &&
19+
github.event.comment.author_association == 'MEMBER' &&
20+
contains(github.event.comment.body, '@claude')) ||
21+
22+
(github.event_name == 'pull_request_review_comment' &&
23+
github.event.comment.author_association == 'MEMBER' &&
24+
contains(github.event.comment.body, '@claude')) ||
25+
26+
(github.event_name == 'pull_request_review' &&
27+
github.event.review.author_association == 'MEMBER' &&
28+
contains(github.event.review.body, '@claude')) ||
29+
30+
(github.event_name == 'issues' &&
31+
github.event.issue.author_association == 'MEMBER' &&
32+
(contains(github.event.issue.body, '@claude') ||
33+
contains(github.event.issue.title, '@claude')))
2034
runs-on: ubuntu-latest
2135
permissions:
2236
contents: read

0 commit comments

Comments
 (0)