workflows/claude: fix PR checkout for fork PRs
When a PR originates from a fork, the PR branch doesn't exist in the origin remote. This adds a step that uses `gh pr checkout` before running the Claude action, which properly handles fork PRs by adding the fork as a remote and fetching the branch from there.
This commit is contained in:
1 parent
19b2ad7979
commit
bcb589cc9e
1 file changed
+12
@@ -30,6 +30,18 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 1
|
fetch-depth: 1
|
||||||
|
|
||||||
|
- name: Checkout PR branch (handles fork PRs)
|
||||||
|
if: github.event.issue.pull_request || github.event_name == 'pull_request_review_comment' || github.event_name == 'pull_request_review'
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
run: |
|
||||||
|
if [ "${{ github.event_name }}" = "issue_comment" ]; then
|
||||||
|
PR_NUMBER=${{ github.event.issue.number }}
|
||||||
|
else
|
||||||
|
PR_NUMBER=${{ github.event.pull_request.number }}
|
||||||
|
fi
|
||||||
|
gh pr checkout "$PR_NUMBER"
|
||||||
|
|
||||||
- name: Run Claude Code
|
- name: Run Claude Code
|
||||||
id: claude
|
id: claude
|
||||||
uses: anthropics/claude-code-action@v1
|
uses: anthropics/claude-code-action@v1
|
||||||
|
|||||||
Reference in new issue
Block a user