Skip to content

Commit 1c265b9

Browse files
committed
Remove claude_pr_review.yml as it turns out there is a GitHub restriction that keeps secrets from being accessed on PRs from forks. We will have to request reviews manually.
* Modify claude.yml 1. Added "Get PR details" step (NEW - lines 28-51) This new step runs ONLY when the trigger is a PR-related comment. It: - Detects if it's a PR comment vs regular issue - Fetches the PR information using GitHub API - Extracts the fork's repository name and commit SHA - Sets them as outputs (steps.pr.outputs.sha and steps.pr.outputs.repo) Why? The original workflow couldn't see fork PR code because it only checked out the main repo. 2. Split checkout into TWO conditional steps (CHANGED - lines 53-62) Before: One checkout step that always checked out main repo with fetch-depth: 1 After: Two checkout steps: - "Checkout PR branch" - Runs if PR details were fetched successfully, checks out the fork's PR branch - "Checkout repository" - Runs otherwise (for regular issues), checks out main repo Why? Need different checkout behavior for PRs (checkout fork) vs issues (checkout main). 3. Changed fetch-depth from 1 to 0 (CHANGED) Before: fetch-depth: 1 (only latest commit) After: fetch-depth: 0 (full git history) Why? Claude Code needs more context to understand the codebase and provide better reviews. Summary The original workflow could only see the main repo's code. When you commented @claude on a fork PR, it would review the wrong code! These changes make it check out the actual PR branch from the fork when reviewing PRs, while keeping the original behavior for regular issues.
1 parent 7e6cc16 commit 1c265b9

2 files changed

Lines changed: 35 additions & 47 deletions

File tree

.github/workflows/claude.yml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,44 @@ jobs:
2727
id-token: write
2828
actions: read
2929
steps:
30+
- name: Get PR details
31+
if: |
32+
(github.event_name == 'issue_comment' && github.event.issue.pull_request) ||
33+
github.event_name == 'pull_request_review_comment' ||
34+
github.event_name == 'pull_request_review'
35+
id: pr
36+
uses: actions/github-script@v7
37+
with:
38+
script: |
39+
let prNumber;
40+
if (context.eventName === 'issue_comment') {
41+
prNumber = context.issue.number;
42+
} else {
43+
prNumber = context.payload.pull_request.number;
44+
}
45+
46+
const pr = await github.rest.pulls.get({
47+
owner: context.repo.owner,
48+
repo: context.repo.repo,
49+
pull_number: prNumber
50+
});
51+
52+
core.setOutput('sha', pr.data.head.sha);
53+
core.setOutput('repo', pr.data.head.repo.full_name);
54+
55+
- name: Checkout PR branch
56+
if: steps.pr.outcome == 'success'
57+
uses: actions/checkout@v4
58+
with:
59+
ref: ${{ steps.pr.outputs.sha }}
60+
repository: ${{ steps.pr.outputs.repo }}
61+
fetch-depth: 0
62+
3063
- name: Checkout repository
64+
if: steps.pr.outcome != 'success'
3165
uses: actions/checkout@v4
3266
with:
33-
fetch-depth: 1
67+
fetch-depth: 0
3468

3569
- name: Run Claude Code
3670
id: claude

.github/workflows/claude_pr_review.yml

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)