-
Notifications
You must be signed in to change notification settings - Fork 2
69 lines (59 loc) · 2.64 KB
/
Copy pathclaude-code-review.yaml
File metadata and controls
69 lines (59 loc) · 2.64 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
name: Claude Code Review
on:
workflow_call:
secrets:
anthropic-api-key:
description: 'Anthropic API key for Claude Code Review'
required: true
concurrency:
group: claude-review-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
claude-review:
# Guards against running in forked orgs. Does NOT gate on fork PRs — callers
# use pull_request_target so secrets are available for fork PRs by design.
# Do not add run/build steps that source checked-out repo files here.
if: github.repository_owner == 'loft-sh'
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 1
persist-credentials: false
- name: Restore CLAUDE.md from base branch
env:
BASE_REF: ${{ github.event.pull_request.base.ref }}
run: |
# Prevent prompt injection via CLAUDE.md in PR head.
# Restore the base-branch version; delete if it doesn't exist there.
git show "origin/${BASE_REF}:CLAUDE.md" > CLAUDE.md 2>/dev/null || rm -f CLAUDE.md
- name: Setup fork as origin for Claude
if: ${{ github.event.pull_request.head.repo.fork == true }}
env:
PR_HEAD_CLONE_URL: ${{ github.event.pull_request.head.repo.clone_url }}
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
run: |
git remote rename origin upstream
git remote add origin "${PR_HEAD_CLONE_URL}"
git fetch origin "${PR_HEAD_REF}"
git checkout -B "${PR_HEAD_REF}" "origin/${PR_HEAD_REF}"
- name: Claude Code Review
uses: anthropics/claude-code-action@f4fb5c6cdccc1ee7af63692f5d08d56efaa64cc8 # v1
with:
anthropic_api_key: ${{ secrets.anthropic-api-key }} # zizmor: ignore[secrets-outside-env] -- API key passed via workflow_call, not a repo secret
github_token: ${{ secrets.GITHUB_TOKEN }}
allowed_bots: "renovate"
track_progress: true
prompt: |
Review PR #${{ github.event.pull_request.number }} in ${{ github.repository }}.
Focus on: bugs, security issues, performance problems.
Skip: style nitpicks, minor suggestions, praise.
Only comment on issues worth fixing. Be concise.
claude_args: |
--allowedTools "Read,Glob,Grep,LS,Bash(git diff:*),Bash(git log:*),mcp__github_inline_comment__create_inline_comment"