Ivan's Blog
主题

GitHub reusable workflow

GitHub reusable workflow 表示仓库把 GitHub Actions 逻辑做成 workflow_call 可复用单元,供其他仓库以薄 caller workflow 调用。它关注安全边界、inputs/secrets contract、template rollout 和多仓库维护成本。 这个 Topic 不等同于“有 GitHub Actions”。

  • 运维
  • 工具

目录

Definition

GitHub reusable workflow 表示仓库把 GitHub Actions 逻辑做成 workflow_call 可复用单元,供其他仓库以薄 caller workflow 调用。它关注安全边界、inputs/secrets contract、template rollout 和多仓库维护成本。

这个 Topic 不等同于“有 GitHub Actions”。它只适用于共享 workflow 本身或明确调用共享 workflow 的仓库,重点是把重复的质量门禁、发布步骤或已被项目选择的 secret-using delivery 收敛成可维护 contract。调用方保留事件监听和 metadata 收集,共享方负责稳定接口和安全执行边界。

When to use

当项目 snapshot 中该模式影响运行、交付、硬件操作或跨仓库复用时使用;如果只是一次性脚本或历史残留,先保留在项目笔记里,不急着提升为 Topic。

当项目证据表明多个仓库正在复用同一段 Actions 逻辑,或者 workflow 会携带 secret、模板、version pin、manual smoke test 与明确的配置所有权时,应使用本 Topic。若只是单仓库内普通 CI、lint、test job,且没有 workflow_call 或跨仓库调用关系,不应提升为 reusable workflow。

Habits / defaults

  • Reusable workflow 只接收必要 metadata 和 secrets,不 checkout caller code。
  • Caller workflow 保持薄,只负责监听事件、收集上下文、调用共享 workflow。
  • 已选定的共享 delivery 需要 manual smoke test 和 template,方便配置迁移或新仓库接入。
  • inputs/secrets contract 必须稳定且最小化;新增字段时要兼容现有 caller,否则一次修改会破坏多个仓库的 release 或通知链路。
  • 带 secret 的 reusable workflow 默认不执行 caller repo code。调用方可以传 repository、run URL、SHA、actor、workflow name 等 metadata,但共享 workflow 不应 checkout 未审查代码后再使用 secret。
  • 每次调整共享 workflow,都要同步检查 caller template、README、manual dispatch smoke path 和配置责任,避免模板继续传播旧 contract。
  • 不存在项目 transport 选择时,不得仅凭这个 Topic 或任意 reference 新建共享 notifier、外部 secret 或渠道;先通过 Release failure notification 的 transport selection gate。

Reference implementations

当前资料库没有登记可作为默认 notifier 的 reusable workflow reference。此 Topic 只保留通用的 workflow_call 接口、安全边界和 rollout 审查合同;新的 reference implementation 必须以已选择的项目 transport 为前提(topics/release-failure-notification/TOPIC.md)。

Failure modes

  • 在 reusable workflow 中执行 caller code 会扩大 secret 信任边界。
  • inputs 不稳定会让调用仓库大面积破坏。
  • 没有 template/configuration sync,推广到多仓库会变成手工配置。
  • 只更新共享 workflow、不更新 caller template,会让新仓库继续复制旧参数或旧权限。模板、README 和 example caller 应与 reusable workflow 同步维护。
  • 在没有项目选择证据时把共享 workflow 设为默认 notifier,会隐式扩大 secret 和渠道范围。该状态必须阻断 rollout,而不是回退到外部 transport(skills/policies/release-failure-notification/assets/templates/release-failure-notification-transport-gate.example.json)。
  • 不做 manual smoke test 会让已选 transport 的配置或 GitHub permission 变更直到真实 release 失败时才暴露;共享 notifier 应保留低成本 dispatch 验证路径。

Evidence index

  • topics/release-failure-notification/TOPIC.md
  • skills/policies/release-failure-notification/assets/templates/release-failure-notification-transport-gate.example.json