fix(ci): fix reviewer assignment permissions for fork PRs#12
fix(ci): fix reviewer assignment permissions for fork PRs#12
Conversation
…er assignment Fork PRs lack write access under `pull_request` trigger, causing reviewer assignment to fail silently. Switch to `pull_request_target` and explicitly grant `pull-requests: write` permission. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
📝 WalkthroughWalkthroughThe GitHub Actions PR reviewer workflow was reconfigured to use Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
.github/workflows/pr-reviewer.yml (1)
4-4: Add a security guardrail comment to prevent future unsafe edits.This workflow is currently safe (metadata-only, no checkout), but with
pull_request_target+ write token, future additions like checkout could introduce a security vulnerability. Add an explicit inline comment near the trigger to prevent risky edits later.Suggested comment diff
on: pull_request_target: + # Security: keep this workflow metadata-only; do not checkout or execute PR head code. branches: [ 'develop', 'release_**' ] types: [ opened, edited, reopened ]🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/pr-reviewer.yml at line 4, The workflow uses the pull_request_target trigger (pull_request_target:) which can be dangerous if future edits add a checkout or write token; add an explicit inline security guardrail comment immediately above or beside the pull_request_target line stating that this workflow must remain metadata-only and must not add actions/steps that perform repository checkout or use a write token (e.g., NO CHECKOUT/NO WRITE TOKEN) to prevent unsafe edits later.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In @.github/workflows/pr-reviewer.yml:
- Line 4: The workflow uses the pull_request_target trigger
(pull_request_target:) which can be dangerous if future edits add a checkout or
write token; add an explicit inline security guardrail comment immediately above
or beside the pull_request_target line stating that this workflow must remain
metadata-only and must not add actions/steps that perform repository checkout or
use a write token (e.g., NO CHECKOUT/NO WRITE TOKEN) to prevent unsafe edits
later.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 682b1739-130f-4d80-9968-a6372c1d7270
📒 Files selected for processing (1)
.github/workflows/pr-reviewer.yml
Summary
pull_requesttrigger topull_request_targetso the workflow has write access when triggered by fork PRspermissionsblock (contents: read,pull-requests: write) for least-privilege accessif: github.event_name == 'pull_request'conditionWhy
Fork PRs running under
pull_requesttrigger only get read-onlyGITHUB_TOKEN, causing the reviewer assignment step to fail silently.pull_request_targetruns in the context of the base repo, granting the necessary write permissions.Test plan
actionlint🤖 Generated with Claude Code
Summary by cubic
Fixes reviewer auto-assignment for PRs from forks. Uses
pull_request_targetwith minimal write access so the workflow can assign reviewers reliably.pull_requesttopull_request_targetto run with base repo permissions.contents: read,pull-requests: write.if: github.event_name == 'pull_request'condition.Written for commit b3327eb. Summary will update on new commits.
Summary by CodeRabbit