Skip to content

ci: publish PR 一打开就把 .deb 自动镜像进 staging(去 fork 依赖,纯 Actions)#71

Merged
eggfly merged 1 commit into
mainfrom
ci/capture-to-staging-6417
Jul 15, 2026
Merged

ci: publish PR 一打开就把 .deb 自动镜像进 staging(去 fork 依赖,纯 Actions)#71
eggfly merged 1 commit into
mainfrom
ci/capture-to-staging-6417

Conversation

@eggfly

@eggfly eggfly commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

目的

czdev 提交的 .deb 目前存在贡献者自己 fork 的 czdev-buffer release 里——fork 一删包就没了。本 PR 用纯 GitHub Actions(不依赖任何 Cloudflare/动态服务器)把这一风险闭环。

内容

1. 新增 capture-to-staging.yml(自动捕获)

  • 触发:pull_request_target,当 PR 改动 pool/main/**/*.deb.release.json 时(opened / synchronize)。
  • 动作:通过 API 读 PR head 上的清单 → 严格校验 filename(Debian 包名模式、不含路径)与 url(必须在 github.com)→ 下载 .deb → sha256 必须与清单一致 → 镜像上传到本仓库的 staging release(已存在同名同内容则跳过)。
  • 安全(pull_request_target 带写权限,已刻意收紧攻击面):
    • 绝不 checkout / 执行 PR 的任何代码,清单只作为数据用 jq 解析;
    • 文件名/URL 都按白名单模式校验,下载物只做哈希校验、永不执行;
    • 语义校验仍由 validate-pr.yml 负责,promote 时还会再验一次 sha256。

2. update-index.yml promote 加回退

提升进 apt-pool 时优先从 staging 镜像取,staging 没有或 sha 不匹配才回退到清单 url(fork)。配合捕获后,即使贡献者删了 fork,已开过 PR 的包也能照常上架。

效果

czdev 开 publish PR(.deb 在 fork buffer)
  → capture-to-staging 立即镜像进 staging(组织可控、永久)
  → 审核合并 → promote 从 staging 取 → apt-pool → 商店

czdev 无需任何改动,开发者无感知。

验证

Add capture-to-staging.yml (pull_request_target): whenever a publish PR
opens or updates a pool/main/**/*.deb.release.json manifest, download the
referenced .deb, verify it against the manifest sha256 and mirror it into
the org-controlled 'staging' release. Pending binaries therefore stop
depending on the contributor's fork staying alive. The PR's code is never
checked out or executed; manifests are read via the API and treated as
data, with strict filename/url validation.

Teach the promote step in update-index.yml to fetch from the staging
mirror first and only fall back to the manifest url, so promotion works
even if the fork or its buffer release has been deleted.
@eggfly
eggfly merged commit f4bb32f into main Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant