fix(ci): checkout pr code instead of base branch in claude review#3545
fix(ci): checkout pr code instead of base branch in claude review#3545FabianKramm merged 1 commit intomainfrom
Conversation
513dc6a to
e81bdb4
Compare
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 513dc6a48c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| git fetch origin ${{ github.event.pull_request.head.ref }} | ||
| git checkout -B ${{ github.event.pull_request.head.ref }} origin/${{ github.event.pull_request.head.ref }} |
There was a problem hiding this comment.
Keep checkout pinned to the event SHA
In fork PRs, this step fetches and checks out the branch ref (origin/${{ github.event.pull_request.head.ref }}) instead of the event’s head.sha, which means if the branch is updated after the event is emitted (e.g., a force‑push or new commit while the job is queued), the workflow can end up reviewing a newer commit than the one that triggered the run. That can lead to comments that don’t match the PR diff for this run; consider fetching and checking out the exact head.sha to keep the review consistent with the event payload.
Useful? React with 👍 / 👎.
pull_request_target defaults to checking out the base branch HEAD, not the PR's actual code. Claude was reviewing main branch content and flagging "missing" changes that the PR itself introduced. Using ref: head.sha ensures we checkout the PR commit. fetch-depth: 0 provides full history for diff/blame operations. Fork handling step configures origin correctly for external contributor PRs. Pattern adopted from vcluster-docs/.github/workflows/claude-review.yml Closes DEVOPS-501
e81bdb4 to
3091a7a
Compare
Summary
Why
pull_request_targetdefaults to checking out base branch, causing Claude to review main instead of PR changes. This led to false positives where Claude flagged code that the PR itself modified.Related PRs
Closes DEVOPS-501