@@ -3,20 +3,29 @@ name: Claude Code Review
33on :
44 pull_request :
55 types : [opened, synchronize, reopened, ready_for_review, labeled]
6+ workflow_dispatch :
7+ inputs :
8+ pr_number :
9+ description : ' PR number to review (for external contributor PRs)'
10+ required : true
11+ type : number
612
713jobs :
814 claude-review :
915 if : |
10- contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.pull_request.author_association) &&
16+ github.event_name == 'workflow_dispatch' ||
1117 (
12- contains(github.event.pull_request.labels.*.name, 'claude-review') ||
18+ contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.pull_request.author_association) &&
1319 (
14- github.actor != 'dependabot[bot]' &&
15- (github.event.pull_request.draft == false || github.event.action == 'ready_for_review')
20+ contains(github.event.pull_request.labels.*.name, 'claude-review') ||
21+ (
22+ github.actor != 'dependabot[bot]' &&
23+ (github.event.pull_request.draft == false || github.event.action == 'ready_for_review')
24+ )
1625 )
1726 )
1827 concurrency :
19- group : claude-review-${{ github.repository }}-${{ github.event.pull_request.number }}
28+ group : claude-review-${{ github.repository }}-${{ github.event.inputs.pr_number || github.event. pull_request.number }}
2029 cancel-in-progress : true
2130 runs-on : ubuntu-latest
2231 permissions :
2534 issues : read
2635 id-token : write
2736 steps :
37+ - name : Resolve PR metadata
38+ id : pr-meta
39+ env :
40+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
41+ EVENT_NAME : ${{ github.event_name }}
42+ INPUT_PR_NUMBER : ${{ github.event.inputs.pr_number }}
43+ PR_EVENT_NUMBER : ${{ github.event.pull_request.number }}
44+ PR_EVENT_HEAD_SHA : ${{ github.event.pull_request.head.sha }}
45+ REPO : ${{ github.repository }}
46+ run : |
47+ if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
48+ PR_DATA=$(gh pr view "$INPUT_PR_NUMBER" --repo "$REPO" --json headRefSha,number --jq '.')
49+ echo "pr_number=$INPUT_PR_NUMBER" >> "$GITHUB_OUTPUT"
50+ echo "head_sha=$(echo "$PR_DATA" | jq -r '.headRefSha')" >> "$GITHUB_OUTPUT"
51+ else
52+ echo "pr_number=$PR_EVENT_NUMBER" >> "$GITHUB_OUTPUT"
53+ echo "head_sha=$PR_EVENT_HEAD_SHA" >> "$GITHUB_OUTPUT"
54+ fi
55+
2856 - name : Checkout repository
2957 uses : actions/checkout@v6
3058 with :
3664 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
3765 OWNER : ${{ github.repository_owner }}
3866 REPO : ${{ github.event.repository.name }}
39- PR_NUMBER : ${{ github.event.pull_request.number }}
67+ PR_NUMBER : ${{ steps.pr-meta.outputs.pr_number }}
4068 run : |
4169 # Query for previous reviews
4270 REVIEWS_JSON=$(gh api graphql -f query='
@@ -117,14 +145,14 @@ jobs:
117145 uses : anthropics/claude-code-action@v1
118146 env :
119147 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
120- PR_NUMBER : ${{ github.event.pull_request.number }}
148+ PR_NUMBER : ${{ steps.pr-meta.outputs.pr_number }}
121149 REPO : ${{ github.repository }}
122- PR_HEAD_SHA : ${{ github.event.pull_request.head.sha }}
150+ PR_HEAD_SHA : ${{ steps.pr-meta.outputs.head_sha }}
123151 with :
124152 claude_code_oauth_token : ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
125153 claude_args : ' --model ${{ vars.CLAUDE_CODE_DEFAULT_MODEL || '' sonnet'' }} --dangerously-skip-permissions --allowed-tools "Bash(gh *),Bash(cat *),Bash(curl *)"'
126154 prompt : |
127- You are reviewing PR #${{ github.event.pull_request.number }} in ${{ github.repository }}.
155+ You are reviewing PR #${{ steps.pr-meta.outputs.pr_number }} in ${{ github.repository }}.
128156
129157 **REQUIRED FIRST STEP:**
130158 Read and understand the CLAUDE.md file in the repository root. This contains critical context about our architecture, conventions, and intentional design decisions.
0 commit comments