fix(ci): add allow-unsafe-pr-checkout for pull_request_target - #33
Conversation
🤖 AI Code Review
📁
|
In pull_request_target, git checkout gets the base branch, not the PR
head. Use gh api pulls/{number}/files to fetch the real diff, and
cache all files in a single JSON response to avoid per-file API calls.
- Fetch changed file list + per-file patches in one API call
- Skip binary/undiffable files via null patch from API
- Remove git diff fallback and virtual-diff logic for new files
背景
PR #31 将 AI Code Review workflow 的 trigger 从
pull_request改为pull_request_target,使 fork PR 能访问SENSENOVA_API_KEY。但actions/checkout@v4新增了安全保护,默认拒绝在pull_request_target下 checkout fork 代码。变更
在 checkout 步骤添加
allow-unsafe-pr-checkout: true,显式放行。安全说明
此 workflow 对 fork 代码只做只读操作,不存在 "pwn request" 风险:
git difffile -b --mime-encodingcurl→ SenseNova APImake/python/./script.shrun:命令 inline 在 workflow yml 中,fork 无法篡改