format-suggest workflow fails on all fork PRs since actions/checkout blocked pull_request_target checkouts
还没有人认领这个 Issue。
评估
调研方向
从 .github/workflows/format-suggest.yaml 开始,将其中的 checkout 步骤与链接的 posit-dev/setup-air 模板进行比较。在选择文档中说明的 checkout 选项或更严格的 workflow 拆分方案之前,先查看 pull_request_target 安全指南。完成的标准是:来自 fork 的 pull request 能够成功运行 format-suggest,同时不会暴露仓库密钥或执行不受信任的代码。
由索引模型根据 Issue 内容生成。
描述
Problem
format-suggest.yaml now fails on every pull request coming from a fork. It dies after ~5s in the actions/checkout step with:
Refusing to check out fork pull request code from a 'pull_request_target' workflow. This workflow runs with the base repository's GITHUB_TOKEN, secrets, default-branch cache scope, and runner access.
Example: #2703 (fork PR, format-suggest failed 2026-09-02). For comparison, #2699 (also a fork PR) still passed on 2026-06-19.
Cause
GitHub changed the default behaviour of actions/checkout: checking out a fork's head SHA under pull_request_target (or workflow_run) is refused unless explicitly opted in. Announced 2026-06-18 for v7, backported to the other supported major versions with enforcement on 2026-07-20 — which is why actions/checkout@v4 (a floating major tag) picked it up without any change on our side.
Since pull_request_target runs the workflow definition from the base branch, contributors cannot fix this in their PRs; it has to be changed on main.
Suggested fix
The upstream template this workflow is derived from, posit-dev/setup-air/examples/format-suggest.yaml, has already been updated:
- uses: actions/checkout@v7
with:
ref: ${{ github.event.pull_request.head.sha }}
allow-unsafe-pr-checkout: true
vs. the current .github/workflows/format-suggest.yaml:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
allow-unsafe-pr-checkout: true is the documented opt-out. It is defensible for this workflow because the checked-out tree is only treated as passive data (air format . does not execute package code), which is the exact use case GitHub calls out as acceptable — but it is worth a conscious decision rather than a copy-paste, so I did not open a PR for it.
The stricter alternative, if you'd rather not opt out at all, is the two-workflow split: run air format . under pull_request (no secrets), upload the diff as an artifact, and post the suggestions from a separate workflow_run job that never checks out fork code.
Other r-lib repos deriving from the same template are presumably affected identically.
References
- 主要语言
- R
- 星标
- 2.5k
- 派生
- 760
- 平均合并
- 1 天 6 小时
- 30 天内合并 PR
- 3
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
r-lib/devtools 的其他 Issue
-
`dev_sitrep()` says to update with `pak::pak("somePackage")` but doing so doesn't change the report可能已有人在做 @fabiandistler 于 82 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 2/5 1-3 小时 新手友好度 52/100
-
难度 5/5 一周以上 新手友好度 25/100
-
devtools::load_all() has an extra warning that pkgload::load_all() doesn't可能已有人在做 @emstruong 于 278 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 45/100
-
难度 5/5 一周以上 新手友好度 30/100
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
hubverse-org/hubDevs#83 ·
-
data_bio2rarify - doc - dimensions wrong可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 1/5 1 小时以内 新手友好度 88/100
leppott/BioMonTools#162 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
bug
难度 1/5 1 小时以内 新手友好度 78/100
-
publications
难度 1/5 1 小时以内 新手友好度 85/100
epiforecasts/epiforecasts.github.io#161 ·
维护者通常 1 天内回复