Skip to content

Commit 057b611

Browse files
a-simeshinclaude
andauthored
Add Claude Code Review workflow
* "Claude PR Assistant workflow" * "Claude Code Review workflow" * Fix permissions for Claude Code Review workflow Change pull-requests and issues permissions from read to write so Claude can leave review comments. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Use ANTHROPIC_API_KEY instead of OAuth token Simplify authentication by using direct API key. Also simplified the review prompt. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Add explicit github_token to workflow OIDC token doesn't work for cross-fork PRs, using explicit GITHUB_TOKEN instead. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Use pull_request_target to access secrets from fork PRs GitHub doesn't pass secrets to workflows triggered by pull_request from forks. Using pull_request_target allows access to secrets while still reviewing the PR code. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Support both auto-review and interactive @claude mentions - pull_request_target: auto-review for all PRs (forks + internal) - issue_comment: respond to @claude mentions in comments - Updated prompt for Java/Spring focus Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent d3867c2 commit 057b611

File tree

2 files changed

+93
-0
lines changed

2 files changed

+93
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Claude Code
2+
3+
on:
4+
# Auto-review on PR events (works for both internal PRs and forks)
5+
pull_request_target:
6+
types: [opened, synchronize, ready_for_review, reopened]
7+
# Interactive mode: respond to @claude mentions in comments
8+
issue_comment:
9+
types: [created]
10+
11+
jobs:
12+
claude:
13+
# Run for PR events OR when @claude is mentioned in a comment
14+
if: |
15+
github.event_name == 'pull_request_target' ||
16+
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude'))
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
20+
pull-requests: write
21+
issues: write
22+
id-token: write
23+
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v4
27+
with:
28+
ref: ${{ github.event.pull_request.head.sha || github.sha }}
29+
fetch-depth: 1
30+
31+
- name: Run Claude
32+
uses: anthropics/claude-code-action@v1
33+
with:
34+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
35+
github_token: ${{ secrets.GITHUB_TOKEN }}
36+
prompt: |
37+
Review this pull request. Focus on:
38+
- Code quality and best practices for Java/Spring
39+
- Potential bugs or issues
40+
- Security concerns
41+
- Performance considerations
42+
Provide constructive feedback in Russian or English based on PR language.
43+

.github/workflows/claude.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Claude Code
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
pull_request_review_comment:
7+
types: [created]
8+
issues:
9+
types: [opened, assigned]
10+
pull_request_review:
11+
types: [submitted]
12+
13+
jobs:
14+
claude:
15+
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')))
20+
runs-on: ubuntu-latest
21+
permissions:
22+
contents: read
23+
pull-requests: read
24+
issues: read
25+
id-token: write
26+
actions: read # Required for Claude to read CI results on PRs
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 1
32+
33+
- name: Run Claude Code
34+
id: claude
35+
uses: anthropics/claude-code-action@v1
36+
with:
37+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
38+
39+
# This is an optional setting that allows Claude to read CI results on PRs
40+
additional_permissions: |
41+
actions: read
42+
43+
# Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it.
44+
# prompt: 'Update the pull request description to include a summary of changes.'
45+
46+
# Optional: Add claude_args to customize behavior and configuration
47+
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
48+
# or https://code.claude.com/docs/en/cli-reference for available options
49+
# claude_args: '--allowed-tools Bash(gh pr:*)'
50+

0 commit comments

Comments
 (0)