-
Notifications
You must be signed in to change notification settings - Fork 245
141 lines (132 loc) · 4.6 KB
/
claude-code-review.yml
File metadata and controls
141 lines (132 loc) · 4.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: Claude Code Review
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
pull_request_review_comment:
types: [created]
issue_comment:
types: [created]
env:
CLAUDE_OPUS_MODEL: claude-opus-4-6
CLAUDE_SONNET_MODEL: claude-sonnet-4-5
concurrency:
group: claude-review-${{ github.event.pull_request.number || github.event.issue.number }}
cancel-in-progress: false
jobs:
code-review:
if: |
(
github.event_name == 'issue_comment' &&
github.event.issue.pull_request &&
contains(github.event.comment.body, '@claude review') &&
(
github.event.comment.author_association == 'MEMBER' ||
github.event.comment.author_association == 'OWNER' ||
github.event.comment.author_association == 'COLLABORATOR'
)
) ||
(
github.event_name == 'pull_request' &&
contains(join(github.event.pull_request.labels.*.name, ','), 'claude-review') &&
github.event.pull_request.head.repo.full_name == github.repository
)
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
pull-requests: write
issues: write
id-token: write
steps:
- name: Get PR SHA
id: pr-sha
uses: actions/github-script@v7
with:
script: |
if (context.eventName === 'issue_comment') {
const { data: pr } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
});
core.setOutput('head_sha', pr.head.sha);
} else {
core.setOutput('head_sha', context.payload.pull_request.head.sha);
}
- name: Checkout repository
uses: actions/checkout@v6
with:
ref: ${{ steps.pr-sha.outputs.head_sha }}
fetch-depth: 0
- name: Run Claude Code Review
uses: anthropics/claude-code-action@v1
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
prompt: "Use agent teams to run /claude-review, then use /inline-pr-comments to post findings as a consolidated PR review with inline comments"
track_progress: true
use_sticky_comment: false
claude_args: |
--model ${{ env.CLAUDE_OPUS_MODEL }}
--allowedTools "Bash(gh api:*)"
interactive:
if: |
(
github.event_name == 'issue_comment' &&
github.event.issue.pull_request &&
contains(github.event.comment.body, '@claude') &&
!contains(github.event.comment.body, '@claude review') &&
(
github.event.comment.author_association == 'MEMBER' ||
github.event.comment.author_association == 'OWNER' ||
github.event.comment.author_association == 'COLLABORATOR'
)
) ||
(
github.event_name == 'pull_request_review_comment' &&
github.event.pull_request.head.repo.full_name == github.repository &&
contains(github.event.comment.body, '@claude') &&
(
github.event.comment.author_association == 'MEMBER' ||
github.event.comment.author_association == 'OWNER' ||
github.event.comment.author_association == 'COLLABORATOR'
)
)
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
pull-requests: write
issues: write
id-token: write
steps:
- name: Get PR SHA
id: pr-sha
uses: actions/github-script@v7
with:
script: |
let prNumber;
if (context.eventName === 'issue_comment') {
prNumber = context.issue.number;
} else if (context.eventName === 'pull_request_review_comment') {
prNumber = context.payload.pull_request.number;
}
if (prNumber) {
const { data: pr } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber
});
core.setOutput('head_sha', pr.head.sha);
}
- name: Checkout repository
uses: actions/checkout@v6
with:
ref: ${{ steps.pr-sha.outputs.head_sha || github.sha }}
fetch-depth: 0
- name: Run Claude Code Assistant
uses: anthropics/claude-code-action@v1
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
track_progress: true
use_sticky_comment: false
claude_args: "--model ${{ env.CLAUDE_SONNET_MODEL }}"