Skip to content

Commit 545f575

Browse files
committed
ci: use official Claude PR review comments
1 parent 3a9155e commit 545f575

1 file changed

Lines changed: 27 additions & 49 deletions

File tree

.github/workflows/claude-code-review.yml

Lines changed: 27 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ name: Claude Code Review
22

33
on:
44
pull_request:
5-
types: [opened, synchronize, ready_for_review]
5+
types: [opened, synchronize, reopened, ready_for_review]
66
branches: [main]
7-
workflow_dispatch:
87

98
permissions:
109
contents: read
@@ -18,11 +17,8 @@ jobs:
1817
runs-on: ubuntu-latest
1918
if: >-
2019
${{
21-
github.event_name == 'workflow_dispatch' ||
22-
(
23-
github.event.pull_request.draft == false &&
24-
contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.pull_request.author_association)
25-
)
20+
github.event.pull_request.draft == false &&
21+
contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.pull_request.author_association)
2622
}}
2723
env:
2824
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
@@ -33,61 +29,43 @@ jobs:
3329
- name: Skip when Claude secrets are not configured
3430
if: ${{ env.ANTHROPIC_API_KEY == '' || env.ANTHROPIC_BASE_URL == '' || env.GH_TOKEN_VALUE == '' }}
3531
run: echo "Claude Code review secrets are not configured; skipping Claude Code review."
32+
3633
- name: Checkout repository
3734
if: ${{ env.ANTHROPIC_API_KEY != '' && env.ANTHROPIC_BASE_URL != '' && env.GH_TOKEN_VALUE != '' }}
38-
uses: actions/checkout@v4
35+
uses: actions/checkout@v6
3936
with:
4037
fetch-depth: 1
4138
persist-credentials: false
39+
4240
- name: Run Claude Code review
43-
id: claude-review
4441
if: ${{ env.ANTHROPIC_API_KEY != '' && env.ANTHROPIC_BASE_URL != '' && env.GH_TOKEN_VALUE != '' }}
45-
continue-on-error: true
4642
uses: anthropics/claude-code-action@v1
43+
env:
44+
ANTHROPIC_BASE_URL: ${{ secrets.ANTHROPIC_BASE_URL }}
4745
with:
4846
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
4947
github_token: ${{ secrets.GH_TOKEN }}
48+
track_progress: true
5049
prompt: |
50+
REPO: ${{ github.repository }}
51+
PR NUMBER: ${{ github.event.pull_request.number }}
52+
5153
Review this pull request using REVIEW.md as the review-only guide.
52-
Focus on actionable VoScript risks: privacy/security leaks, model lifecycle races,
53-
GPU/CPU fallback behavior, HTTP API compatibility, regression-test coverage, and
54-
synchronized English/Chinese documentation. Avoid formatting-only comments.
54+
Focus on actionable VoScript risks:
55+
- Privacy and security leaks
56+
- Model lifecycle races and GPU/CPU fallback behavior
57+
- HTTP API compatibility
58+
- Regression-test coverage
59+
- Synchronized English/Chinese documentation
60+
61+
The PR branch is already checked out in the current working directory.
62+
Always post one top-level review summary with `gh pr comment`, even when there are no actionable findings.
63+
If there are no actionable findings, say that explicitly in the top-level comment.
64+
Use `mcp__github_inline_comment__create_inline_comment` with `confirmed: true` for specific changed-line issues.
65+
Avoid formatting-only comments.
66+
Only post GitHub comments; do not leave review text only in the action transcript.
67+
5568
claude_args: |
5669
--model ${{ env.CLAUDE_MODEL }}
5770
--max-turns 30
58-
env:
59-
ANTHROPIC_BASE_URL: ${{ secrets.ANTHROPIC_BASE_URL }}
60-
61-
- name: Post Claude Code review summary
62-
if: ${{ always() && github.event_name == 'pull_request' && env.ANTHROPIC_API_KEY != '' && env.ANTHROPIC_BASE_URL != '' && env.GH_TOKEN_VALUE != '' }}
63-
env:
64-
GH_TOKEN: ${{ secrets.GH_TOKEN }}
65-
PR_NUMBER: ${{ github.event.pull_request.number }}
66-
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
67-
CLAUDE_OUTCOME: ${{ steps.claude-review.outcome }}
68-
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
69-
MARKER: "<!-- claude-code-review-summary -->"
70-
run: |
71-
set -euo pipefail
72-
short_sha="${HEAD_SHA:0:7}"
73-
if [ "$CLAUDE_OUTCOME" = "success" ]; then
74-
body="$(printf '%s\n### Claude Code Review\n\nClaude Code Review completed for `%s`.\n\nThis summary is posted even when Claude has no line-level findings. If no separate Claude inline comments are visible, there were no actionable line-level findings for this run.\n\nRun: %s' "$MARKER" "$short_sha" "$RUN_URL")"
75-
else
76-
body="$(printf '%s\n### Claude Code Review\n\nClaude Code Review did not complete successfully for `%s`.\n\nCheck the workflow run before merging. The check will remain failed so this cannot be missed.\n\nRun: %s' "$MARKER" "$short_sha" "$RUN_URL")"
77-
fi
78-
79-
comment_id="$(
80-
gh api "repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/comments" --paginate \
81-
--jq ".[] | select(.body | contains(\"$MARKER\")) | .id" | tail -n 1
82-
)"
83-
if [ -n "$comment_id" ]; then
84-
jq -n --arg body "$body" '{body: $body}' \
85-
| gh api -X PATCH "repos/$GITHUB_REPOSITORY/issues/comments/$comment_id" --input -
86-
else
87-
jq -n --arg body "$body" '{body: $body}' \
88-
| gh api -X POST "repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/comments" --input -
89-
fi
90-
91-
- name: Fail when Claude Code review failed
92-
if: ${{ steps.claude-review.outcome == 'failure' }}
93-
run: exit 1
71+
--allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(git diff:*),Bash(rg:*)"

0 commit comments

Comments
 (0)