3636 run : echo "Approved review of ${{ github.event.pull_request.head.sha }}"
3737
3838 claude-review :
39- name : Claude review
39+ name : Generate Claude review
4040 needs : approve_review
4141 if : >-
4242 always() &&
@@ -48,233 +48,25 @@ jobs:
4848 ) ||
4949 needs.approve_review.result == 'success'
5050 )
51- runs-on : ubuntu-latest
52- environment : ai-pr-review-runtime
53- timeout-minutes : 45
5451 permissions :
5552 contents : read
5653 id-token : write
5754 pull-requests : read
58-
59- steps :
60- # pull_request_target exposes repository secrets, so only check out the
61- # exact trusted base revision. The PR's code is never checked out.
62- - name : Check out base branch
63- uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
64- with :
65- fetch-depth : 1
66- persist-credentials : false
67- ref : ${{ github.event.pull_request.base.sha }}
68-
69- - name : Reserve AI review toolkit path
70- run : |
71- if [[ -e .ai-review-toolkit ]]; then
72- echo "::error::The trusted base contains the reserved AI review toolkit path."
73- exit 1
74- fi
75-
76- # Load support files from the same immutable revision as this workflow.
77- - name : Check out AI review toolkit
78- uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
79- with :
80- repository : ${{ job.workflow_repository }}
81- ref : ${{ job.workflow_sha }}
82- path : .ai-review-toolkit
83- sparse-checkout : |
84- .github/prompts
85- scripts
86- persist-credentials : false
87-
88- - name : Resolve AI review prompt
89- id : review-prompt
90- env :
91- CUSTOM_PROMPT_PATH : ${{ inputs['prompt-path'] }}
92- run : |
93- prompt_path="$(
94- bash .ai-review-toolkit/scripts/resolve_ai_review_prompt.sh \
95- "$CUSTOM_PROMPT_PATH"
96- )"
97- echo "path=$prompt_path" >> "$GITHUB_OUTPUT"
98-
99- - name : Prepare pull request review context
100- env :
101- EXPECTED_BASE_SHA : ${{ github.event.pull_request.base.sha }}
102- EXPECTED_HEAD_SHA : ${{ github.event.pull_request.head.sha }}
103- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
104- PR_NUMBER : ${{ github.event.pull_request.number }}
105- run : bash .ai-review-toolkit/scripts/prepare_ai_review_context.sh
106-
107- - name : Prepare review inputs
108- id : review-inputs
109- env :
110- REVIEW_PROMPT_PATH : ${{ steps.review-prompt.outputs.path }}
111- run : |
112- {
113- echo 'prompt<<AI_REVIEW_PROMPT'
114- cat "$REVIEW_PROMPT_PATH"
115- echo 'AI_REVIEW_PROMPT'
116- echo "schema=$(jq -c . .ai-review-toolkit/.github/prompts/ai-pr-review-schema.json)"
117- } >> "$GITHUB_OUTPUT"
118-
119- - name : Prepare unprivileged Claude user
120- run : |
121- bash .ai-review-toolkit/scripts/prepare_ai_review_user.sh claude-review
122-
123- # The Claude CLI runs through sudo. Preserve only its Bedrock
124- # credentials and the action's subprocess-isolation controls.
125- sudo sh -c \
126- 'printf "%s\n" \
127- "Defaults:runner env_keep += \"AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN AWS_REGION AWS_DEFAULT_REGION AWS_BEARER_TOKEN_BEDROCK\"" \
128- "Defaults:runner env_keep += \"ANTHROPIC_BEDROCK_BASE_URL CLAUDE_CODE_USE_BEDROCK CLAUDE_CODE_ENTRYPOINT CLAUDE_CODE_ACTION CLAUDE_CODE_ATTRIBUTION_HEADER\"" \
129- "Defaults:runner env_keep += \"CLAUDE_CODE_SUBPROCESS_ENV_SCRUB CLAUDE_CODE_SCRIPT_CAPS DETAILED_PERMISSION_MESSAGES\"" \
130- > /etc/sudoers.d/claude-review-env'
131- sudo chmod 440 /etc/sudoers.d/claude-review-env
132- sudo visudo -cf /etc/sudoers.d/claude-review-env
133-
134- - name : Configure AWS credentials for Claude
135- uses : aws-actions/configure-aws-credentials@517a711dbcd0e402f90c77e7e2f81e849156e31d # v6.2.2
136- with :
137- role-to-assume : ${{ secrets.BEDROCK_ROLE_ARN }}
138- role-session-name : claude-pr-review-${{ github.run_id }}
139- aws-region : us-east-1
140- inline-session-policy : |
141- {
142- "Version": "2012-10-17",
143- "Statement": [{
144- "Effect": "Allow",
145- "Action": [
146- "bedrock:InvokeModel",
147- "bedrock:InvokeModelWithResponseStream"
148- ],
149- "Resource": "*"
150- }]
151- }
152- mask-aws-account-id : true
153- output-env-credentials : true
154-
155- - name : Review pull request with Claude on Amazon Bedrock
156- id : review
157- continue-on-error : true
158- uses : anthropics/claude-code-action@fa7e2f0a29a126f0b81cdcf360561b36e44cf608 # v1.0.180
159- env :
160- AWS_REGION : us-east-1
161- CLAUDE_CODE_ATTRIBUTION_HEADER : " 0"
162- with :
163- github_token : ${{ secrets.GITHUB_TOKEN }}
164- use_bedrock : " true"
165- path_to_claude_code_executable : ${{ github.workspace }}/.ai-review-toolkit/scripts/run_claude_isolated.sh
166- # This also keeps the token out of the git remote configured by the action.
167- allowed_non_write_users : ${{ github.actor }}
168- classify_inline_comments : " false"
169- prompt : ${{ steps.review-inputs.outputs.prompt }}
170- claude_args : |
171- --model us.anthropic.claude-opus-4-8
172- --max-turns 20
173- --allowedTools "Read,Grep,Glob"
174- --disallowedTools "Bash,Write,Edit,NotebookEdit,WebFetch,WebSearch"
175- --json-schema '${{ steps.review-inputs.outputs.schema }}'
176-
177- - name : Retry pull request review with Claude on Amazon Bedrock
178- id : review-retry
179- if : steps.review.outcome == 'failure'
180- uses : anthropics/claude-code-action@fa7e2f0a29a126f0b81cdcf360561b36e44cf608 # v1.0.180
181- env :
182- AWS_REGION : us-east-1
183- CLAUDE_CODE_ATTRIBUTION_HEADER : " 0"
184- with :
185- github_token : ${{ secrets.GITHUB_TOKEN }}
186- use_bedrock : " true"
187- path_to_claude_code_executable : ${{ github.workspace }}/.ai-review-toolkit/scripts/run_claude_isolated.sh
188- # This also keeps the token out of the git remote configured by the action.
189- allowed_non_write_users : ${{ github.actor }}
190- classify_inline_comments : " false"
191- prompt : ${{ steps.review-inputs.outputs.prompt }}
192- claude_args : |
193- --model us.anthropic.claude-opus-4-8
194- --max-turns 20
195- --allowedTools "Read,Grep,Glob"
196- --disallowedTools "Bash,Write,Edit,NotebookEdit,WebFetch,WebSearch"
197- --json-schema '${{ steps.review-inputs.outputs.schema }}'
198-
199- - name : Save Claude review
200- env :
201- CLAUDE_EXECUTION_FILE : >-
202- ${{
203- steps.review.outcome == 'success' &&
204- steps.review.outputs.execution_file ||
205- steps.review-retry.outputs.execution_file
206- }}
207- run : |
208- set -euo pipefail
209-
210- if [[ ! -r "$CLAUDE_EXECUTION_FILE" ]]; then
211- echo "::error::Claude execution output is not readable."
212- exit 1
213- fi
214-
215- jq -e '
216- [
217- .[]
218- | select(.type == "result" and has("structured_output"))
219- | .structured_output
220- ] as $reviews
221- | if (
222- ($reviews | length) == 1 and
223- ($reviews[0] | type == "object" and keys == ["comments", "summary"])
224- ) then
225- $reviews[0]
226- else
227- error("Claude returned invalid structured review output")
228- end
229- ' "$CLAUDE_EXECUTION_FILE" > "${RUNNER_TEMP}/claude-review.json"
230-
231- - name : Upload Claude review
232- uses : actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
233- with :
234- name : claude-review-${{ github.run_id }}
235- path : ${{ runner.temp }}/claude-review.json
236- if-no-files-found : error
237- overwrite : true
238- retention-days : 1
55+ uses : ./.github/workflows/claude-review.yml
56+ with :
57+ prompt-path : ${{ inputs['prompt-path'] }}
58+ secrets : inherit
23959
24060 claude-review-comment :
24161 name : Post Claude review
24262 needs : claude-review
243- runs-on : ubuntu-latest
244- timeout-minutes : 10
63+ if : >-
64+ always() &&
65+ needs.claude-review.result == 'success'
24566 permissions :
24667 contents : read
24768 pull-requests : write
248-
249- steps :
250- - name : Download Claude review
251- uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
252- with :
253- name : claude-review-${{ github.run_id }}
254- path : ${{ runner.temp }}/claude-review
255-
256- - name : Check out AI review toolkit
257- uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
258- with :
259- repository : ${{ job.workflow_repository }}
260- ref : ${{ job.workflow_sha }}
261- path : .ai-review-toolkit
262- sparse-checkout : scripts
263- persist-credentials : false
264-
265- - name : Post Claude review
266- env :
267- EXPECTED_BASE_SHA : ${{ github.event.pull_request.base.sha }}
268- EXPECTED_HEAD_SHA : ${{ github.event.pull_request.head.sha }}
269- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
270- PR_NUMBER : ${{ github.event.pull_request.number }}
271- REVIEW_FILE : ${{ runner.temp }}/claude-review/claude-review.json
272- run : |
273- bash .ai-review-toolkit/scripts/post_ai_review.sh \
274- claude \
275- "$EXPECTED_BASE_SHA" \
276- "$EXPECTED_HEAD_SHA" \
277- "$REVIEW_FILE"
69+ uses : ./.github/workflows/claude-review-comment.yml
27870
27971 codex-review :
28072 name : Generate Codex review
30193 codex-review-comment :
30294 name : Post Codex review
30395 needs : codex-review
96+ if : >-
97+ always() &&
98+ needs.codex-review.result == 'success'
30499 permissions :
305100 contents : read
306101 pull-requests : write
0 commit comments