ci(pr-agent): support fork PRs via pull_request_target with collaborator allowlist#19
Merged
Merged
Conversation
genni613
approved these changes
Apr 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
PR #18 来自 fork (
genni613/CodePlanGUI),workflow 日志显示:原因:GitHub 对 fork 发起的
pull_request事件强制不注入 secrets(与 PR 作者权限无关,只看 head repo 是否跨仓库),所以 pr-agent 拿不到OPENAI_KEY,三个 auto 动作全部跳过,job 以 success 收尾但 0 评论 —— 正是 #18 没 CR 结果的根因。修改
pull_request_target—— 能访问 secrets;使用 base 分支的 workflow 文件,fork 无法通过修改 yaml 绕过保护。OWNER / MEMBER / COLLABORATOR的 PR 跑,外部贡献者 fork PR 直接跳过,防 workflow injection 泄漏 key。CONFIG.AI_PROVIDER/CONFIG.MODEL→CONFIG__AI_PROVIDER/CONFIG__MODEL,符合 pr-agent 的 Dynaconf 分层规范(点号在 shell env 名里非法)。synchronize类型,让 PR 后续 push 也能重跑 review。安全边界
actions/checkout去 checkout PR head 并执行任何命令,否则pull_request_target+ 执行不受信代码 = 经典 pwn request 漏洞。ci.yml仍用普通pull_request(read-only token、无 secrets),fork 代码在它里面跑测试是安全的,不受此改动影响。验证
合并后让 genni613 在 #18 上 push 一次(或关了重开),应能看到 pr-agent 正常评论。