优化 Docker 发布流程,默认单架构构建#18
Merged
Merged
Conversation
There was a problem hiding this comment.
AI PR Review
Decision: comment
Confidence: 0.88
Summary
整体改动方向合理:按触发场景动态选择平台并优化缓存策略,能显著降低常规构建耗时。工作流语法和主要逻辑看起来一致,未发现明确阻断合并的问题。
Findings
- [minor] .github/workflows/docker-publish.yml:40 -
Set up QEMU的启用条件仅判断平台字符串是否包含arm。但workflow_dispatch的platforms输入是通用的,若手动传入linux/s390x、linux/ppc64le等非 arm 的跨架构平台,将不会启用 QEMU,可能导致构建失败。建议将条件改为检测“是否包含非 amd64 平台”或显式限制输入仅允许amd64/arm64。 - [minor] .github/workflows/docker-publish.yml:35 - 手动输入
platforms缺少兜底校验。当前仅做了去空白处理,若输入为空串(例如仅空格)会将空值写入platforms输出,后续build-push-action可能报错。建议在标准化后为空时回退到linux/amd64或直接 fail fast 给出明确错误。
Recent Comment Summary
建议补充 platforms 输入的健壮性:1) QEMU 条件不要只匹配 arm,避免其他跨架构输入构建失败;2) 对空输入增加兜底或失败提示。其余变更思路清晰,可读性也不错。
Contributor
Author
|
补充 CI 说明:
|
There was a problem hiding this comment.
AI PR Review
Decision: comment
Confidence: 0.90
Summary
整体改动方向清晰,流程逻辑自洽:按触发类型选择平台、按平台条件启用 QEMU、并根据单/多架构切换 GHA cache mode,能够达到“默认单架构提速、正式发布保留多架构”的目标。未发现会直接导致流程错误或发布失败的阻塞问题。
Findings
- [minor] .github/workflows/docker-publish.yml:5 - 当前
push仅监听main与v*tag。若团队仍有“非 main 分支也需要自动构建镜像用于验证”的场景,此改动会使这类构建不再触发。建议在 PR 描述或仓库文档中明确该行为变更是有意收敛,而非遗漏。
Recent Comment Summary
实现质量良好、无阻塞性问题;建议补充文档说明 push 触发范围收敛到 main/tag 的行为变化,避免团队误解。
Owner
|
感谢贡献!PR 已通过 squash merge 合并到 合并前我做了增量复查和一个最小 hardening:
验证结果:
再次感谢你对 Docker 发布耗时优化的贡献。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
当前 Docker 发布流程固定构建
linux/amd64,linux/arm64,普通分支构建和手动触发都会启用多架构构建与 QEMU,耗时较长。改动
main分支 push 触发 Docker 发布流程,默认只构建linux/amd64。linux/amd64,linux/arm64,保留正式版本的多架构镜像。workflow_dispatch新增platforms输入,默认linux/amd64,需要时可手动指定多架构。arm时启用 QEMU。cache-to=type=gha,mode=min,多架构构建继续使用mode=max。验证
git diff --check.github/workflows/docker-publish.ymlgo run github.com/rhysd/actionlint/cmd/actionlint@latest .github/workflows/docker-publish.ymllinux/amd64+cache_mode=minlinux/amd64,linux/arm64+cache_mode=maxlinux/amd64+cache_mode=minlinux/amd64,linux/arm64+cache_mode=maxCloses #9