Skip to content

Commit 2348a86

Browse files
tianjianjiangclaude
andcommitted
ci: fix Claude Code Review workflow to post PR comments
The Claude Code Review workflow was not posting comments on PRs due to: 1. Insufficient permissions: pull-requests: read (needs write to post) 2. Max turns exhaustion: Claude ran out of 5 turns before posting 3. No guidance for fork PR behavior Changes: - Update permissions from pull-requests: read to pull-requests: write to allow posting PR review comments - Increase max-turns from 5 to 10 to ensure Claude completes review and successfully posts the comment - Add comprehensive documentation about fork PR approval requirements and setup instructions for maintainers - Add inline comment explaining the permission change This fixes the issue where Claude would analyze PRs but never post the review comments. With write permissions and more turns, Claude can now complete the review cycle and post feedback. Fork PRs will require manual approval by maintainers (security best practice to prevent secret exfiltration). Related: #722 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 23ece10 commit 2348a86

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,21 @@ on:
1414

1515
jobs:
1616
claude-review:
17-
# Optional: Filter by PR author
18-
# if: |
19-
# github.event.pull_request.user.login == 'external-contributor' ||
20-
# github.event.pull_request.user.login == 'new-developer' ||
21-
# github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'
17+
# Note: For pull requests from forks, this workflow requires manual approval
18+
# by a repository maintainer before it will run. This is a security measure
19+
# to prevent malicious actors from accessing repository secrets.
20+
#
21+
# To enable fork PR reviews:
22+
# 1. Go to Settings → Actions → General
23+
# 2. Under "Fork pull request workflows from outside collaborators"
24+
# 3. Select "Require approval for all outside collaborators"
25+
#
26+
# Maintainers: Review the PR code first, then approve the workflow run if safe.
2227

2328
runs-on: ubuntu-latest
2429
permissions:
2530
contents: read
26-
pull-requests: read
31+
pull-requests: write # Changed from read to write - needed to post PR comments
2732
issues: read
2833
id-token: write
2934

@@ -68,5 +73,6 @@ jobs:
6873
6974
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
7075
# or https://docs.claude.com/en/docs/claude-code/cli-reference for available options
71-
claude_args: '--allowed-tools "Bash(gh issue view:*),Bash(gh search:*),Bash(gh issue list:*),Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr list:*)" --max-turns 5'
76+
# Increased max-turns to 10 to ensure Claude has enough iterations to complete review and post comment
77+
claude_args: '--allowed-tools "Bash(gh issue view:*),Bash(gh search:*),Bash(gh issue list:*),Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr list:*)" --max-turns 10'
7278

0 commit comments

Comments
 (0)