Skip to content

image workflow 支持发布公开镜像到 ghcr.io #14

Closed

Description

@RiriAgent

必须先读

目标

image workflow 能把公开镜像发布到 ghcr.io/<仓库 owner>/,凭调用方授予的 packages: write 使用 GITHUB_TOKEN 推送;私有镜像仍发布到 registry.237575.xyz/。

使用场景

public 仓库(如 mouriya-s-lab/paseo)在 images 中列 ghcr.io/mouriya-s-lab/paseo,不传 Keycloak secret;publish 运行推送不可变 tag 与通道 tag 到 ghcr,按原顺序校验 revision、发信号。

上下文

  • Repo: mouriya-devops/ci,public,默认分支 main。
  • Anchors(基准 mouriya-devops/ci@652c2be):
    • .github/workflows/image.yml parse:repo_re 只匹配 registry.237575.xyz/;publish 模式无条件要求 KEYCLOAK_REGISTRY_CLIENT_SECRET。
    • publish job:REGISTRY: registry.237575.xyz;Fetch registry token 走 Keycloak;registry API 读取用 sa-registry 用户。
    • selftest/image/build.sh:镜像名写死 registry.237575.xyz/ci-selftest/<role>。

问题

  • 2026-11-14 操作员裁定:公开仓库的镜像是公开镜像,应发布到 ghcr.io,不放内网 registry。image.yml 只接受 registry.237575.xyz/,public 消费仓 mouriya-s-lab/paseo 无法发布到 ghcr。

责任与必要决策

预期结果

  • 结果 1:images 全部位于 ghcr.io/<github.repository_owner 小写>/ 时,publish 不需要 Keycloak secret,以 GITHUB_TOKEN 推送不可变 tag 与通道 tag,回读 revision 等于检出提交。
  • 结果 2:images 混用两个 registry,或 ghcr 路径不属于调用仓 owner 时,parse 失败并指出该行。
  • 结果 3:registry.237575.xyz/ 镜像的发布行为不变。

范围边界

  • 不应残留: 只接受 registry.237575.xyz/ 的输入校验;写死 registry 的自检夹具。
  • 不在范围: 消费仓改动。

约束

影响范围

  • service

测试形态

最薄入口

验收标准

# 面 Dimension Check Command Env Expect
1 service integration 覆盖 结果 1:ghcr 发布 合并后 gh workflow run selftest-image.yml -R mouriya-devops/ci --ref main -f mode=publish -f channel=latest -f images=$'ghcr.io/mouriya-devops/ci-selftest/alpha\nghcr.io/mouriya-devops/ci-selftest/beta';gh run view <run> --log | grep -E 'Fetch registry token|built=|published=';docker buildx imagetools inspect ghcr.io/mouriya-devops/ci-selftest/alpha:latest --format '{{json .Image.Config.Labels}}' ci main 合并后 success;无 Keycloak 步骤执行;published=true;未登录读取的 revision label 等于 main 提交
2 service integration 覆盖 结果 2:混用与越权 owner 被拒 gh workflow run selftest-image.yml -R mouriya-devops/ci --ref main -f images=$'ghcr.io/mouriya-devops/ci-selftest/alpha\nregistry.237575.xyz/ci-selftest/beta' 与 -f images=ghcr.io/mouriya-s-lab/ci-selftest-alpha 各一次;gh run view <run> --log-failed | grep 'invalid input images' 同上 两次 failure,错误各指出出错行
3 service integration 覆盖 结果 3 [保持]:内网 registry 仍要求 Keycloak secret、build-only 不变 gh workflow run selftest-image.yml -R mouriya-devops/ci --ref main -f mode=publish(ci 仓无 Keycloak secret);gh workflow run selftest-image.yml -R mouriya-devops/ci --ref main;分别 gh run view <run> --log | grep -E 'KEYCLOAK_REGISTRY_CLIENT_SECRET|built=' 同上 前者 failure 且报 secret 必需于 registry.237575.xyz;后者 success、built=true

依赖关系

Activity

  1. RiriAgent commented on Nov 14, 2026

    @RiriAgent
    ContributorAuthor

    决策:ci 仓没有 Keycloak secret,第 3 行改为验证内网 registry 发布仍强制要求该 secret,以及 build-only 不变;内网发布的正向路径由各私有消费仓的发布持续覆盖。ghcr 包默认私有:已在 mouriya-devops 与 mouriya-s-lab 组织的 Packages 设置中允许创建 public 容器包,并把 ci-selftest/alpha、ci-selftest/beta 设为 public。

  2. RiriAgent commented on Nov 14, 2026

    @RiriAgent
    ContributorAuthor

    验收:PR #15 已合并(66d9711)。第 1 行:run 43607510463 发布到 ghcr.io/mouriya-devops/ci-selftest/{alpha,beta},Fetch registry token 为 skipped,published=true,未登录读取两镜像 revision 均为 66d9711。第 2 行:混用 registry(43607512747)与越权 owner(43607514754)均在 parse 失败并指出出错行。第 3 行:内网 registry 发布缺 secret 仍被拒(43607516782),build-only 成功(43607827024)。证据包 https://github.com/mouriya-devops/ci/pull/15#issuecomment-6879345769(3/3)。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions