1515 discussions : write
1616 id-token : write
1717 statuses : write
18+ workflow : write
19+ actions : write
1820 steps :
1921 - name : Checkout code
2022 uses : actions/checkout@v4
@@ -25,19 +27,32 @@ jobs:
2527 - name : Checkout PR branch if needed
2628 if : github.event.issue.pull_request
2729 env :
28- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
30+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
2931 run : |
3032 # Get the PR number from the issue object
3133 PR_NUMBER="${{ github.event.issue.number }}"
3234
3335 echo "Checking out PR #${PR_NUMBER}"
3436
35- # Use GitHub CLI to checkout the PR
36- # This handles both internal branches and forks automatically
37- gh pr checkout ${PR_NUMBER}
37+ # Get PR info
38+ PR_INFO=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
39+ "https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER")
3840
39- echo "Current branch: $(git branch --show-current)"
41+ # Extract the PR branch ref and other details
42+ PR_BRANCH=$(echo "$PR_INFO" | jq -r .head.ref)
43+ PR_SHA=$(echo "$PR_INFO" | jq -r .head.sha)
44+ PR_REPO=$(echo "$PR_INFO" | jq -r .head.repo.full_name)
45+
46+ echo "PR branch is $PR_BRANCH from repo $PR_REPO with commit SHA $PR_SHA"
47+
48+ # Fetch the PR as a local branch (works for forks too)
49+ git fetch origin "pull/$PR_NUMBER/head:pr-$PR_NUMBER"
50+ git checkout "pr-$PR_NUMBER"
51+
52+ # Verify checkout
53+ echo "Current branch details:"
4054 git status
55+ git rev-parse HEAD
4156
4257 - name : Claude Response
4358 uses : anthropics/claude-code-action@beta
0 commit comments