-
-
Notifications
You must be signed in to change notification settings - Fork 0
Add Claude Code GitHub Workflow #30
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
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,44 @@ | ||
| name: Claude Code Review | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, ready_for_review, reopened] | ||
| # Optional: Only run on specific file changes | ||
| # paths: | ||
| # - "src/**/*.ts" | ||
| # - "src/**/*.tsx" | ||
| # - "src/**/*.js" | ||
| # - "src/**/*.jsx" | ||
|
|
||
| jobs: | ||
| claude-review: | ||
| # Optional: Filter by PR author | ||
| # if: | | ||
| # github.event.pull_request.user.login == 'external-contributor' || | ||
| # github.event.pull_request.user.login == 'new-developer' || | ||
| # github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' | ||
|
|
||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| pull-requests: read | ||
| issues: read | ||
| id-token: write | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 1 | ||
|
|
||
| - name: Run Claude Code Review | ||
| id: claude-review | ||
| uses: anthropics/claude-code-action@v1 | ||
| with: | ||
| claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} | ||
| plugin_marketplaces: 'https://github.com/anthropics/claude-code.git' | ||
| plugins: 'code-review@claude-code-plugins' | ||
| prompt: '/code-review:code-review ${{ github.repository }}/pull/${{ github.event.pull_request.number }}' | ||
| # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md | ||
| # or https://code.claude.com/docs/en/cli-reference for available options | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,50 @@ | ||||||||||||||||||||||||||
| 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'))) | ||||||||||||||||||||||||||
|
Comment on lines
+15
to
+19
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. 🧩 Analysis chain🏁 Script executed: # First, let's examine the actual workflow file to confirm the code and check for permission checks
cat -n .github/workflows/claude.ymlRepository: greenpill-dev-guild/cookie-jar Length of output: 2309 🏁 Script executed: # Check if there are any other permission configurations in the workflow
git ls-files ".github/workflows/*.yml" | head -20Repository: greenpill-dev-guild/cookie-jar Length of output: 392 🏁 Script executed: # Let's also check if there's documentation or code for the claude-code-action
find . -name "*.yml" -o -name "*.yaml" | xargs grep -l "claude" | head -10Repository: greenpill-dev-guild/cookie-jar Length of output: 147 🌐 Web query:
💡 Result: REST API (resources)
Webhooks (event payloads)
GraphQL API
Important gotcha: “Events API” payloads
Sources: 🌐 Web query:
💡 Result:
Events where
For other triggers, either there is no Related note: GitHub announced removal of Citations:
🏁 Script executed: # Check if there's any documentation or code in the repo about permissions
rg -i "author_association|collaborator|permission" --type yml --type yaml --type mdRepository: greenpill-dev-guild/cookie-jar Length of output: 101 🌐 Web query:
💡 Result: In the What it means: Possible values (GitHub’s Note: GitHub’s webhook “issues” docs don’t enumerate every field inside the nested References: 🌐 Web query:
💡 Result: In the Inside the Possible Note: GitHub announced removing Sources: [1] [2] [3] [4] 🌐 Web query:
💡 Result: When does the removal take effect? What exactly changed? Impact (what breaks / what you need to do)
What Sources 🏁 Script executed: # Search for any permission checks in the repo related to this workflow
rg -i "author_association|permission.*check|write.*access" --type-listRepository: greenpill-dev-guild/cookie-jar Length of output: 463 🏁 Script executed: # Let's check the repo for any GitHub Actions configurations that might restrict access
rg "write" .github/workflows/ -A 2 -B 2Repository: greenpill-dev-guild/cookie-jar Length of output: 1407 Restrict workflow to authorized users by checking author association. The However, note that GitHub deprecated Consider the proposed fix: Restrict to collaborators 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')))
+ (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude') &&
+ github.event.comment.author_association != 'NONE') ||
+ (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude') &&
+ github.event.comment.author_association != 'NONE') ||
+ (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude') &&
+ github.event.review.author_association != 'NONE') ||
+ (github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')) &&
+ github.event.issue.author_association != 'NONE')For stricter control, replace 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||
| contents: read | ||||||||||||||||||||||||||
| pull-requests: read | ||||||||||||||||||||||||||
| issues: read | ||||||||||||||||||||||||||
| id-token: write | ||||||||||||||||||||||||||
| actions: read # Required for Claude to read CI results on PRs | ||||||||||||||||||||||||||
|
Comment on lines
+21
to
+26
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. Same permissions issue: Same as the review workflow — Claude needs write access to post comments. Proposed fix permissions:
contents: read
- pull-requests: read
- issues: read
+ pull-requests: write
+ issues: write
id-token: write
actions: read # Required for Claude to read CI results on PRs📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||
| - name: Checkout repository | ||||||||||||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||
| fetch-depth: 1 | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| - name: Run Claude Code | ||||||||||||||||||||||||||
| id: claude | ||||||||||||||||||||||||||
| uses: anthropics/claude-code-action@v1 | ||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||
| claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # This is an optional setting that allows Claude to read CI results on PRs | ||||||||||||||||||||||||||
| additional_permissions: | | ||||||||||||||||||||||||||
| actions: read | ||||||||||||||||||||||||||
| # Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it. | ||||||||||||||||||||||||||
| # prompt: 'Update the pull request description to include a summary of changes.' | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # Optional: Add claude_args to customize behavior and configuration | ||||||||||||||||||||||||||
| # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md | ||||||||||||||||||||||||||
| # or https://code.claude.com/docs/en/cli-reference for available options | ||||||||||||||||||||||||||
| # claude_args: '--allowed-tools Bash(gh pr:*)' | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
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
🏁 Script executed:
Repository: greenpill-dev-guild/cookie-jar
Length of output: 392
🏁 Script executed:
# Read the workflow file to see the complete configuration cat -n .github/workflows/claude-code-review.ymlRepository: greenpill-dev-guild/cookie-jar
Length of output: 1814
🌐 Web query:
claude-code-action GitHub permissions requirements💡 Result:
claude-code-actionGitHub permission requirements1) GitHub App permissions (recommended auth)
Your GitHub App (custom app or the official Claude app) needs these Repository permissions:
2) Workflow
permissions:block (GITHUB_TOKEN / job token scopes)In the workflow that runs
anthropics/claude-code-action@v1, set at least:[1]
If you’re using AWS Bedrock or Google Vertex via GitHub OIDC, also add:
[1]
Sources: Anthropic Claude Code GitHub Actions docs / examples. [1][2]
pull-requests,issues, andcontentspermissions should bewrite.The Claude Code Review action requires write access to post review comments and update repository content. The current permissions are insufficient:
pull-requests: read→ should bepull-requests: writeissues: read→ should beissues: writecontents: read→ should becontents: writeWithout these permissions, the action will fail when attempting to create review comments on the PR.
Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents