Skip to content

Commit 51bb27d

Browse files
authored
chore: update claude review workflows (#61)
1 parent 0d0c15c commit 51bb27d

2 files changed

Lines changed: 46 additions & 16 deletions

File tree

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

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,23 @@ jobs:
2222
outputs:
2323
run_review: ${{ steps.check.outputs.run_review }}
2424
steps:
25-
- name: Check for exact @claude review command
25+
- name: Check for @claude review on its own line
2626
id: check
2727
env:
2828
COMMENT_BODY: ${{ github.event.comment.body }}
2929
run: |
30-
body="$(python - <<'PY'
30+
has_review_command="$(python - <<'PY'
3131
import os
32+
3233
body = os.environ.get("COMMENT_BODY", "")
33-
print(" ".join(body.split()))
34+
print(
35+
"true"
36+
if any(line.strip() == "@claude review" for line in body.splitlines())
37+
else "false"
38+
)
3439
PY
3540
)"
36-
if [ "$body" = "@claude review" ]; then
41+
if [ "$has_review_command" = "true" ]; then
3742
echo "run_review=true" >> "$GITHUB_OUTPUT"
3843
else
3944
echo "run_review=false" >> "$GITHUB_OUTPUT"
@@ -44,7 +49,15 @@ jobs:
4449
if: |
4550
always() &&
4651
(
47-
(github.event_name == 'pull_request' && github.event.pull_request.user.type != 'Bot') ||
52+
(
53+
github.event_name == 'pull_request' &&
54+
github.event.pull_request.user.type != 'Bot' &&
55+
github.event.pull_request.draft == false &&
56+
contains(fromJson('["OWNER","MEMBER","COLLABORATOR"]'), github.event.pull_request.author_association) &&
57+
!contains(github.event.pull_request.labels.*.name, 'skip-ai-review') &&
58+
!contains(github.event.pull_request.labels.*.name, 'dependencies') &&
59+
!contains(github.event.pull_request.labels.*.name, 'chore')
60+
) ||
4861
needs.detect-claude-command.outputs.run_review == 'true'
4962
)
5063
runs-on:
@@ -53,9 +66,10 @@ jobs:
5366
PR_NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }}
5467
permissions:
5568
contents: read
56-
pull-requests: read
69+
pull-requests: write
5770
issues: read
5871
id-token: write
72+
actions: read
5973

6074
steps:
6175
- name: Checkout repository
@@ -65,13 +79,24 @@ jobs:
6579

6680
- name: Run Claude Code Review
6781
id: claude-review
68-
uses: anthropics/claude-code-action@v1
82+
uses: anthropics/claude-code-action@88c168b39e7e64da0286d812b6e9fbebb6708185
6983
with:
7084
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
85+
track_progress: >-
86+
${{
87+
(
88+
github.event_name == 'pull_request' &&
89+
contains(fromJson('["opened","synchronize","ready_for_review","reopened"]'), github.event.action)
90+
) ||
91+
(
92+
github.event_name == 'issues' &&
93+
contains(fromJson('["opened","edited","labeled","assigned"]'), github.event.action)
94+
)
95+
}}
7196
plugin_marketplaces: 'https://github.com/anthropics/claude-code.git'
7297
plugins: 'code-review@claude-code-plugins'
7398
prompt: '/code-review:code-review ${{ github.repository }}/pull/${{ env.PR_NUMBER }}'
7499

75100
# Tools based on CLAUDE.md development commands
76101
# Includes: uv (pytest, alembic, python), pnpm (check, lint, test), and gh CLI
77-
claude_args: '--allowed-tools "Bash(uv run pytest:*),Bash(uv run alembic:*),Bash(uv run python:*),Bash(uv sync:*),Bash(pnpm install:*),Bash(pnpm check:*),Bash(pnpm lint:*),Bash(pnpm format:*),Bash(pnpm test:*),Bash(pnpm build:*),Bash(gh issue:*),Bash(gh pr:*),Bash(gh search:*)"'
102+
claude_args: '--allowed-tools "mcp__github_inline_comment__create_inline_comment,Bash(uv run pytest:*),Bash(uv run alembic:*),Bash(uv run python:*),Bash(uv sync:*),Bash(pnpm install:*),Bash(pnpm check:*),Bash(pnpm lint:*),Bash(pnpm format:*),Bash(pnpm test:*),Bash(pnpm build:*),Bash(gh issue:*),Bash(gh pr:*),Bash(gh search:*)" --model claude-opus-4-6'

.github/workflows/claude.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ on:
1313
jobs:
1414
detect-non-claude-review:
1515
name: Skip Exact @claude Review Command
16-
runs-on: ubuntu-latest
1716
permissions: {}
17+
runs-on: ubuntu-latest
1818
outputs:
1919
run_claude: ${{ steps.check.outputs.run_claude }}
2020
steps:
21-
- name: Skip exact @claude review command
21+
- name: Skip comments with @claude review on its own line
2222
id: check
2323
env:
2424
EVENT_NAME: ${{ github.event_name }}
@@ -28,13 +28,18 @@ jobs:
2828
echo "run_claude=true" >> "$GITHUB_OUTPUT"
2929
exit 0
3030
fi
31-
body="$(python - <<'PY'
31+
has_review_command="$(python - <<'PY'
3232
import os
33+
3334
body = os.environ.get("COMMENT_BODY", "")
34-
print(" ".join(body.split()))
35+
print(
36+
"true"
37+
if any(line.strip() == "@claude review" for line in body.splitlines())
38+
else "false"
39+
)
3540
PY
3641
)"
37-
if [ "$body" = "@claude review" ]; then
42+
if [ "$has_review_command" = "true" ]; then
3843
echo "run_claude=false" >> "$GITHUB_OUTPUT"
3944
else
4045
echo "run_claude=true" >> "$GITHUB_OUTPUT"
@@ -75,8 +80,8 @@ jobs:
7580
runs-on: ubuntu-latest
7681
permissions:
7782
contents: read
78-
pull-requests: read
79-
issues: read
83+
pull-requests: write
84+
issues: write
8085
id-token: write
8186
actions: read # Required for Claude to read CI results on PRs
8287
steps:
@@ -87,7 +92,7 @@ jobs:
8792

8893
- name: Run Claude Code
8994
id: claude
90-
uses: anthropics/claude-code-action@v1
95+
uses: anthropics/claude-code-action@88c168b39e7e64da0286d812b6e9fbebb6708185
9196
with:
9297
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
9398

0 commit comments

Comments
 (0)