@@ -65,69 +65,12 @@ jobs:
6565 steps :
6666 # Checkout the repository at the appropriate commit for review
6767 - name : Checkout repository
68- uses : actions/checkout@v4
68+ uses : actions/checkout@v6
6969 with :
70- # Use PR head SHA for pull_request_target, fallback to current SHA otherwise
71- fetch-depth : 0
72- ref : ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.sha }}
73-
74- # Handle fork branches for pull_request_target events
75- - name : Setup Fork Remote (for pull_request_target)
76- if : ${{ github.event_name == 'pull_request_target' }}
77- env :
78- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
79- PR_NUMBER : ${{ github.event.pull_request.number }}
80- PR_HEAD_REF : ${{ github.event.pull_request.head.ref }}
81- PR_HEAD_OWNER : ${{ github.event.pull_request.head.repo.owner.login }}
82- PR_HEAD_REPO : ${{ github.event.pull_request.head.repo.name }}
83- REPO_OWNER : ${{ github.repository_owner }}
84- run : |
85- PR_NUMBER="$PR_NUMBER"
86- HEAD_REF="$PR_HEAD_REF"
87- HEAD_OWNER="$PR_HEAD_OWNER"
88- HEAD_REPO="$PR_HEAD_REPO"
89- CURRENT_OWNER="$REPO_OWNER"
90-
91- # For forked PRs, temporarily change origin URL to fork repository
92- # This allows claude-code-action to fetch the PR branch correctly
93- if [ "$HEAD_OWNER" != "$CURRENT_OWNER" ]; then
94- echo "PR is from fork: $HEAD_OWNER/$HEAD_REPO"
95- FORK_URL="https://github.com/$HEAD_OWNER/$HEAD_REPO.git"
96- echo "Temporarily changing origin URL to fork: $FORK_URL"
97- git remote set-url origin "$FORK_URL"
98- git fetch origin "$HEAD_REF"
99- git branch "$HEAD_REF" "origin/$HEAD_REF" 2>/dev/null || git branch -f "$HEAD_REF" "origin/$HEAD_REF"
100- fi
101-
102- # For comment-driven triggers, ensure we have the correct PR branch checked out
103- - name : Checkout PR Branch (for comments)
104- if : ${{ github.event_name == 'issue_comment' || github.event_name == 'pull_request_review_comment' }}
105- env :
106- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
107- run : |
108- PR_NUMBER=${{ github.event.issue.number || github.event.pull_request.number }}
109-
110- # Fetch PR metadata: head branch name and source repository
111- PR_DATA=$(gh pr view $PR_NUMBER --json headRefName,headRepositoryOwner,headRepository,baseRefName)
112- HEAD_REF=$(echo "$PR_DATA" | jq -r '.headRefName')
113- HEAD_OWNER=$(echo "$PR_DATA" | jq -r '.headRepositoryOwner.login')
114- HEAD_REPO=$(echo "$PR_DATA" | jq -r '.headRepository.name')
115- BASE_BRANCH=$(echo "$PR_DATA" | jq -r '.baseRefName')
116- CURRENT_OWNER="${{ github.repository_owner }}"
117-
118- # For forked PRs, temporarily change origin URL to fork repository
119- # This allows claude-code-action to fetch the PR branch correctly
120- if [ "$HEAD_OWNER" != "$CURRENT_OWNER" ]; then
121- echo "PR is from fork: $HEAD_OWNER/$HEAD_REPO"
122- FORK_URL="https://github.com/$HEAD_OWNER/$HEAD_REPO.git"
123- echo "Temporarily changing origin URL to fork: $FORK_URL"
124- git remote set-url origin "$FORK_URL"
125- fi
126-
127- # Fetch and checkout the PR branch
128- git fetch origin "$HEAD_REF"
129- git branch "$HEAD_REF" "origin/$HEAD_REF" 2>/dev/null || git branch -f "$HEAD_REF" "origin/$HEAD_REF"
130- git checkout "$HEAD_REF"
70+ # Use PR head SHA for pull_request_target to review the actual PR code
71+ # For comment events, this will default to the base branch (PR context is inferred by Claude action)
72+ ref : ${{ github.event.pull_request.head.sha || github.sha }}
73+ fetch-depth : 1
13174
13275 # Invoke Claude to perform an automated PR review with progress tracking
13376 - name : PR Review with Progress Tracking
@@ -176,4 +119,3 @@ jobs:
176119 # Restrict tools that Claude can use during the review
177120 claude_args : |
178121 --allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*)"
179-
0 commit comments