From 98d898aba9d5a2a8642abf832f1aba3b9695e8dc Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 10 Mar 2026 11:26:36 -0400 Subject: [PATCH] Fix the Claude action for external PRs (#21629) --- .github/workflows/claude.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/claude.yml b/.github/workflows/claude.yml index d300267f1..fd1b528f3 100644 --- a/.github/workflows/claude.yml +++ b/.github/workflows/claude.yml @@ -30,9 +30,21 @@ jobs: with: fetch-depth: 1 + # Workaround for claude-code-action bug with fork PRs: The action tries to fetch by branch name, which doesn't + # exist on origin for forks. Pre-fetch the PR ref so it's available as a local ref. + - name: Fetch fork PR ref (if applicable) + if: github.event.issue.pull_request != '' && github.event.issue.pull_request != null + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + PR_NUMBER=$(gh pr view ${{ github.event.issue.number }} --json number -q .number 2>/dev/null || echo "") + if [ -n "$PR_NUMBER" ]; then + git fetch origin refs/pull/${PR_NUMBER}/head:refs/remotes/pull/${PR_NUMBER}/head || true + fi + - name: Run Claude Code id: claude - uses: anthropics/claude-code-action@v1 + uses: anthropics/claude-code-action@e763fe78de2db7389e04818a00b5ff8ba13d1360 # v1 with: claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}