fix: use pull_request_target for CodeRabbit review trigger#1583
Conversation
The workflow was failing with 403 "Resource not accessible by integration" on fork PRs because pull_request events get read-only GITHUB_TOKEN permissions for cross-repository PRs. Switching to pull_request_target runs the workflow in the base repo context, granting write permissions needed to post the @coderabbitai review comment. This is safe because the workflow only posts a comment and does not check out or execute any code from the PR branch. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🤖 Augment PR SummarySummary: Updates the CodeRabbit “Ready for review” workflow trigger to use 🤖 Was this summary useful? React with 👍 or 👎 |
📝 WalkthroughWalkthroughThe GitHub Actions workflow trigger for CodeRabbit review is changed from Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
Suggested reviewers
🚥 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 |
Summary
pull_requesttopull_request_targetso the workflow runs in the base repo context with write permissions, which is required for fork PRsContext
The workflow triggers when a draft PR is marked "ready for review" to request a CodeRabbit review via comment. For cross-repository (fork) PRs, GitHub restricts
GITHUB_TOKENto read-only onpull_requestevents regardless of declared permissions.pull_request_targetresolves this by running in the base repo context.Failed run: https://github.com/bmad-code-org/BMAD-METHOD/actions/runs/21776395455
Test plan
@coderabbitai reviewcomment successfully🤖 Generated with Claude Code