Skip to content

Commit 513dc6a

Browse files
committed
fix(ci): checkout pr code instead of base branch in claude review
pull_request_target defaults to checking out the base branch HEAD, not the PR's actual code. Claude was reviewing main branch content and flagging "missing" changes that the PR itself introduced. Using ref: head.sha ensures we checkout the PR commit. fetch-depth: 0 provides full history for diff/blame operations. Fork handling step configures origin correctly for external contributor PRs. Pattern adopted from vcluster-docs/.github/workflows/claude-review.yml Closes DEVOPS-501
1 parent fd932f5 commit 513dc6a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,16 @@ jobs:
2828
- name: Checkout repository
2929
uses: actions/checkout@v4
3030
with:
31-
fetch-depth: 1
31+
ref: ${{ github.event.pull_request.head.sha }}
32+
fetch-depth: 0
33+
34+
- name: Setup fork as origin for Claude
35+
if: ${{ github.event.pull_request.head.repo.fork == true }}
36+
run: |
37+
git remote rename origin upstream
38+
git remote add origin ${{ github.event.pull_request.head.repo.clone_url }}
39+
git fetch origin ${{ github.event.pull_request.head.ref }}
40+
git checkout -B ${{ github.event.pull_request.head.ref }} origin/${{ github.event.pull_request.head.ref }}
3241
3342
- name: Run Claude Code Review
3443
id: claude-review

0 commit comments

Comments
 (0)