-
Notifications
You must be signed in to change notification settings - Fork 3.1k
[origin] added claude code review CI workflow #33040
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| name: 'Check: Code Review' | ||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize] | ||
| jobs: | ||
| review: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: anthropics/claude-code-action@v1 | ||
| with: | ||
| anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} | ||
| prompt: "Review this pull request for code quality, correctness, and security. Analyze the diff, then post your findings as review comments." | ||
| claude_args: "--max-turns 5" | ||
|
Comment on lines
+5
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Add concurrency control to avoid duplicate reviews on rapid pushes.
♻️ Proposed addition jobs:
review:
runs-on: ubuntu-latest
+ concurrency:
+ group: claude-review-${{ github.event.pull_request.number }}
+ cancel-in-progress: true
steps:🤖 Prompt for AI Agents🧩 Analysis chain🌐 Web query:
💡 Result: The anthropics/claude-code-action v1 primarily uses the official Claude Code GitHub App for GitHub API operations, including posting PR review comments. This app requires Pull Requests: Read & Write permissions (along with Contents and Issues Read & Write). When using a custom GitHub token via the github_token input (e.g., for custom GitHub Apps), the token must have equivalent repo-scoped permissions: pull-requests: write (minimum for posting comments), plus contents: write and issues: write for full functionality like code changes and issue responses. Workflow permissions must also include pull-requests: write and typically id-token: write for OIDC auth, contents: read/write, and issues: read/write as shown in examples. Citations:
Add The job lacks explicit Proposed fix jobs:
review:
runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ pull-requests: write
+ issues: write
steps:🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| name: Claude Code | ||
|
|
||
| on: | ||
| issue_comment: | ||
| types: [created] | ||
| pull_request_review_comment: | ||
| types: [created] | ||
| issues: | ||
| types: [opened, assigned] | ||
| pull_request_review: | ||
| types: [submitted] | ||
|
|
||
| jobs: | ||
| claude: | ||
| if: | | ||
| (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) || | ||
| (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) || | ||
| (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) || | ||
| (github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude'))) | ||
| runs-on: ubuntu-latest | ||
|
Comment on lines
+13
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Consider adding concurrency control to prevent overlapping runs. Rapid successive events (e.g., multiple ♻️ Proposed addition jobs:
claude:
+ concurrency:
+ group: claude-${{ github.event.issue.number || github.event.pull_request.number }}
+ cancel-in-progress: false
if: |🤖 Prompt for AI Agents |
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
| issues: write | ||
| id-token: write | ||
| actions: read # Required for Claude to read CI results on PRs | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 1 | ||
|
|
||
| - name: Run Claude Code | ||
| id: claude | ||
| uses: anthropics/claude-code-action@v1 | ||
| with: | ||
| anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} | ||
|
|
||
| # Optional: Customize the trigger phrase (default: @claude) | ||
| # trigger_phrase: "/claude" | ||
|
|
||
| # Optional: Trigger when specific user is assigned to an issue | ||
| # assignee_trigger: "claude-bot" | ||
|
|
||
| # Optional: Configure Claude's behavior with CLI arguments | ||
| # claude_args: | | ||
| # --model claude-opus-4-1-20250805 | ||
| # --max-turns 10 | ||
| # --allowedTools "Bash(npm install),Bash(npm run build),Bash(npm run test:*),Bash(npm run lint:*)" | ||
| # --system-prompt "Follow our coding standards. Ensure all new code has tests. Use TypeScript for new files." | ||
|
|
||
| # Optional: Advanced settings configuration | ||
| # settings: | | ||
| # { | ||
| # "env": { | ||
| # "NODE_ENV": "test" | ||
| # } | ||
| # } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
GitHub Actions pull_request event secrets not available from forks💡 Result:
Yes, in GitHub Actions, repository secrets (other than GITHUB_TOKEN) are not available to workflows triggered by the pull_request event when the PR originates from a fork. This is a security feature to prevent malicious actors from accessing secrets via PRs from forked repositories. Key points: - For pull_request event from forks: No access to base repo secrets. GITHUB_TOKEN is read-only. - This applies to both public and private repos (private repos have an opt-in setting for write tokens but secrets remain unavailable). - Fork repo's own secrets are also not passed to the base repo workflow. - To access secrets, use pull_request_target event, which runs in the base repo context with secrets access. However, this is risky: do not checkout or execute untrusted PR code without safeguards (e.g., check user permissions, require approval). - Alternatives: Use workflow_run triggered after a pull_request workflow completes, or OIDC for cloud auth without long-lived secrets. - Enable repo settings like "Require approval for first-time contributors" and read-only GITHUB_TOKEN by default. This behavior is unchanged as of 2026.
Citations:
🏁 Script executed:
# Check the full content of the check_review.yml workflow file cat -n .github/workflows/check_review.ymlRepository: musescore/MuseScore
Length of output: 601
🏁 Script executed:
Repository: musescore/MuseScore
Length of output: 2774
🏁 Script executed:
Repository: musescore/MuseScore
Length of output: 3435
🏁 Script executed:
Repository: musescore/MuseScore
Length of output: 1158
This workflow will not function for external contributors submitting PRs from forks.
On
pull_requestevents from forked repositories, GitHub does not expose repository secrets (includingANTHROPIC_API_KEY), so the workflow will fail silently for the majority of external contributors. Since your README explicitly invites fork contributions ("Fork and make pull requests!"), this is a significant limitation.Options:
pull_request_target— requires careful security review, as it runs base-branch code with write permissions and secret access; the Claude action must be properly sandboxed and the PR code must never be executed.pull_request(no secrets) uploads the diff as an artifact, then aworkflow_run-triggered workflow processes it with secrets.See
triage_prs.ymlfor how your repo already handles fork PRs with secrets in similar workflows.🤖 Prompt for AI Agents