Skip to content

Commit 62ae523

Browse files
committed
fix: use pull_request_target for Claude review to support fork PRs
GitHub does not grant OIDC tokens to pull_request events from forks, causing the Claude Code action to fail. Switching to pull_request_target runs the workflow in the base repo context with access to OIDC and secrets. Also grants write permissions for pull-requests and issues so the action can post review comments.
1 parent b142a13 commit 62ae523

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

.github/workflows/claude-code-review.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Claude Code Review
22

33
on:
4-
pull_request:
4+
pull_request_target:
55
types: [opened, synchronize, ready_for_review, reopened]
66
# Optional: Only run on specific file changes
77
# paths:
@@ -21,14 +21,15 @@ jobs:
2121
runs-on: ubuntu-latest
2222
permissions:
2323
contents: read
24-
pull-requests: read
25-
issues: read
24+
pull-requests: write
25+
issues: write
2626
id-token: write
2727

2828
steps:
2929
- name: Checkout repository
3030
uses: actions/checkout@v4
3131
with:
32+
ref: ${{ github.event.pull_request.head.sha }}
3233
fetch-depth: 1
3334

3435
- name: Run Claude Code Review
@@ -41,4 +42,3 @@ jobs:
4142
prompt: '/code-review:code-review ${{ github.repository }}/pull/${{ github.event.pull_request.number }}'
4243
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
4344
# or https://code.claude.com/docs/en/cli-reference for available options
44-

.github/workflows/claude.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ jobs:
2020
runs-on: ubuntu-latest
2121
permissions:
2222
contents: read
23-
pull-requests: read
24-
issues: read
23+
pull-requests: write
24+
issues: write
2525
id-token: write
2626
actions: read # Required for Claude to read CI results on PRs
2727
steps:

0 commit comments

Comments
 (0)