Skip to content

Commit 5722eb5

Browse files
authored
CI: Restrict Claude Code triggers to users with write-access (#874)
1 parent e9ea2aa commit 5722eb5

1 file changed

Lines changed: 36 additions & 30 deletions

File tree

.github/workflows/claude.yaml

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ jobs:
2020
# Auto-review for same-repo PRs
2121
claude-review:
2222
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
23-
runs-on: ubuntu-latest
23+
runs-on: warp-ubuntu-latest-x64-8x
2424
steps:
25-
- uses: actions/checkout@v4
25+
- uses: actions/checkout@v6
2626
with:
2727
fetch-depth: 1
2828
- uses: anthropics/claude-code-action@v1
@@ -36,30 +36,30 @@ jobs:
3636
REPO: ${{ github.repository }}
3737
PR NUMBER: ${{ github.event.pull_request.number }}
3838
39-
Act as a code reviewer for this pull request. Focus your review on:
39+
Review this PR. Focus on:
4040
- Overall code quality and adherence to best practices
4141
- Possible bugs, edge cases, or logical errors
4242
- Security concerns or unsafe patterns
43-
- Performance characteristics and potential optimizations
43+
- Performance characteristics, issues and potential optimizations
4444
45-
Provide thorough, actionable feedback, and use inline comments for any line-specific issues you identify.
45+
Be concise. Only comment on issues that need attention - no praise or positive comments.
4646
47-
Note: The PR branch is already checked out in the current working directory.
48-
49-
Use `gh pr comment` for summary or top-level feedback on the PR.
50-
Use `mcp__github_inline_comment__create_inline_comment` to annotate specific code issues inline.
51-
Only post GitHub comments - don't submit review text as messages.
52-
Use top-level comments for general observations or praise.
47+
Notes:
48+
- The PR branch is already checked out in the current working directory.
49+
- Use `gh pr comment` for summary or top-level feedback on the PR.
50+
- Use `mcp__github_inline_comment__create_inline_comment` to annotate specific code issues inline.
51+
- Only use inline comments for problems, not praise.
5352
5453
# Manual review triggered by "@claude review" comment (works for forks too)
5554
claude-manual-review:
5655
if: |
5756
github.event_name == 'issue_comment' &&
5857
github.event.issue.pull_request &&
59-
contains(github.event.comment.body, '@claude review')
60-
runs-on: ubuntu-latest
58+
contains(github.event.comment.body, '@claude review') &&
59+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association)
60+
runs-on: warp-ubuntu-latest-x64-8x
6161
steps:
62-
- uses: actions/checkout@v4
62+
- uses: actions/checkout@v6
6363
with:
6464
fetch-depth: 1
6565
- name: Checkout PR branch
@@ -77,31 +77,37 @@ jobs:
7777
REPO: ${{ github.repository }}
7878
PR NUMBER: ${{ github.event.issue.number }}
7979
80-
Act as a code reviewer for this pull request. Focus your review on:
80+
Review this PR. Focus on:
8181
- Overall code quality and adherence to best practices
8282
- Possible bugs, edge cases, or logical errors
8383
- Security concerns or unsafe patterns
84-
- Performance characteristics and potential optimizations
85-
86-
Provide thorough, actionable feedback, and use inline comments for any line-specific issues you identify.
84+
- Performance characteristics, issues and potential optimizations
8785
88-
Note: The PR branch is already checked out in the current working directory.
86+
Be concise. Only comment on issues that need attention - no praise or positive comments.
8987
90-
Use `gh pr comment` for summary or top-level feedback on the PR.
91-
Use `mcp__github_inline_comment__create_inline_comment` to annotate specific code issues inline.
92-
Only post GitHub comments - don't submit review text as messages.
93-
Use top-level comments for general observations or praise.
88+
Notes:
89+
- The PR branch is already checked out in the current working directory.
90+
- Use `gh pr comment` for summary or top-level feedback on the PR.
91+
- Use `mcp__github_inline_comment__create_inline_comment` to annotate specific code issues inline.
92+
- Only use inline comments for problems, not praise.
9493
9594
# General interactive mode - responds to @claude mentions (but NOT review requests on PRs)
95+
# Restricted to users with write access (OWNER, MEMBER, COLLABORATOR)
9696
claude-response:
9797
if: |
98-
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude') && !contains(github.event.comment.body, '@claude review')) ||
99-
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude') && !contains(github.event.comment.body, '@claude review')) ||
100-
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude') && !contains(github.event.review.body, '@claude review')) ||
101-
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
102-
runs-on: ubuntu-latest
98+
(
99+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association) ||
100+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.review.author_association) ||
101+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.issue.author_association)
102+
) && (
103+
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude'))) ||
104+
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
105+
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude') && !contains(github.event.comment.body, '@claude review')) ||
106+
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude') && !contains(github.event.review.body, '@claude review'))
107+
)
108+
runs-on: warp-ubuntu-latest-x64-8x
103109
steps:
104-
- uses: actions/checkout@v4
110+
- uses: actions/checkout@v6
105111
with:
106112
fetch-depth: 1
107113
- name: Checkout PR branch (if on a PR)
@@ -114,4 +120,4 @@ jobs:
114120
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
115121
claude_args: |
116122
--model opus \
117-
--allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr create:*),Bash(git checkout:*),Bash(git add:*),Bash(git commit:*),Bash(git push:*),Bash(git branch:*),Edit,Write,MultiEdit"
123+
--allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr create:*),Bash(git checkout:*),Bash(git add:*),Bash(git commit:*),Bash(git push:*),Bash(git branch:*),Edit,Write,MultiEdit"

0 commit comments

Comments
 (0)