Fix Claude checkout issue for forked PRs

- Add environment overrides to prevent PR branch checkout
- Add explicit github_token for authentication
- Add direct_prompt to guide Claude to use diff file
- Override GITHUB_REF and GITHUB_SHA to stay on base branch
This commit is contained in:
Rasmus Widing
2025-08-19 11:00:33 +03:00
parent 506cbc18c4
commit a00883ac5e

View File

@@ -142,12 +142,24 @@ jobs:
id: claude
uses: anthropics/claude-code-action@beta
timeout-minutes: 15
env:
# Override to prevent checkout of PR branch
GITHUB_REF: refs/heads/${{ github.event.repository.default_branch }}
GITHUB_SHA: ${{ github.event.pull_request.base.sha || github.sha }}
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
# Explicitly provide GitHub token
github_token: ${{ secrets.GITHUB_TOKEN }}
# Trigger phrase for manual reviews
trigger_phrase: "@claude-review-fork"
# Tell Claude to analyze the diff file instead of checking out code
direct_prompt: |
IMPORTANT: Analyze the pr-diff.patch file that has already been created in the current directory.
Do NOT attempt to checkout any code. The diff file contains all the changes you need to review.
# Custom instructions for fork review
custom_instructions: |
You are performing a CODE REVIEW ONLY for a PULL REQUEST FROM A FORK. You cannot make any changes to files.