Skip to content

Conversation

@magisk317
Copy link
Contributor

@magisk317 magisk317 commented Oct 21, 2025

fixes #3119


Motivation / 动机

  • 在主分支合入新代码时希望自动生成供测试环境使用的镜像,以便及时验证最新提交。
  • 现有工作流仅在打标签时构建,无法覆盖主分支的日常增量更新。

Modifications / 改动点

  • 更新 /.github/workflows/docker-image.yml
    • 新增对 master 分支 push 的触发。
    • 新增 Resolve build version 步骤,区分标签、手动触发与分支构建,主分支固定输出 test 版本号。
    • 调整 docker/build-push-action 标签逻辑:标签构建继续推送 latest,主分支推送 astrbot:test(同步到 DockerHub 与 GHCR)。

Verification Steps / 验证步骤

  1. 在本地提交改动并推送至 master(或在 fork/测试仓库的同名分支模拟)。
  2. 前往 GitHub Actions,确认工作流因 master push 被触发并成功完成。
  3. 检查 DockerHub 仓库 <DOCKER_HUB_USERNAME>/astrbot:test 是否更新为最新镜像(可通过标签时间或 docker pull 查看)。
  4. 若发布新标签(如 v4.3.4),再次确认工作流推送了 latest 与版本号标签,确保标签发布逻辑未回归。

Screenshots or Test Results / 运行截图或测试结果

Compatibility & Breaking Changes / 兼容性与破坏性变更

  • 这是一个破坏性变更 (Breaking Change)。/ This is a breaking change.
  • 这不是一个破坏性变更。/ This is NOT a breaking change.

Checklist / 检查清单

  • 😊 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。/ If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
  • 👀 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”。/ My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
  • 🤓 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到了 requirements.txtpyproject.toml 文件相应位置。/ I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.
  • 😮 我的更改没有引入恶意代码。/ My changes do not introduce malicious code.

Sourcery 总结

master 分支推送时触发 Docker 镜像构建,添加一个版本解析步骤以区分标签、分支和手动触发的构建,并更新 build-push-action 的标签逻辑,为 master 分支生成 'test' 镜像并正确管理 'latest' 和版本标签。

CI:

  • master 分支推送时触发工作流,并添加一个版本解析步骤,以区分标签、分支和手动触发的构建(为 master 分支分配 'test')。
  • 更新 docker/build-push-action 的标签以使用解析后的版本,为 master 构建推送 'astrbot:test',并为稳定版本提供条件性的 'latest' 和发布标签。
Original summary in English

Summary by Sourcery

Trigger Docker image builds on master branch pushes, add a version resolution step to differentiate tag, branch, and manual dispatch builds, and update the build-push-action tagging logic to generate 'test' images for master and manage 'latest' and version tags correctly.

CI:

  • Trigger workflow on master branch pushes and add a version resolution step that distinguishes tag, branch, and manual dispatch builds (assigning 'test' for master).
  • Update docker/build-push-action tagging to use the resolved version, pushing 'astrbot:test' for master builds and conditional 'latest' and release tags for stable releases.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你好 - 我已审阅了你的更改 - 以下是一些反馈:

  • 版本解析的组合 if/else 逻辑相当复杂——考虑将 master‐push 和 tag‐release 构建拆分为单独的工作流或作业,以简化维护。
  • 依赖 github.ref_type/ref_name 可能很脆弱——解析 github.ref (refs/heads/… vs refs/tags/…) 在不同的 GitHub 事件类型中更健壮。
  • 为每个 master 构建使用静态“test”标签会覆盖之前的镜像;考虑附加一个简短的提交 SHA 或构建号,以便更好地追溯测试镜像。
给 AI 代理的提示
请处理此代码审查中的评论:

## 总体评论
- 版本解析的组合 if/else 逻辑相当复杂——考虑将 master‐push 和 tag‐release 构建拆分为单独的工作流或作业,以简化维护。
- 依赖 github.ref_type/ref_name 可能很脆弱——解析 github.ref (refs/heads/… vs refs/tags/…) 在不同的 GitHub 事件类型中更健壮。
- 为每个 master 构建使用静态“test”标签会覆盖之前的镜像;考虑附加一个简短的提交 SHA 或构建号,以便更好地追溯测试镜像。

Sourcery 对开源免费 - 如果你喜欢我们的评论,请考虑分享它们 ✨
帮助我更有用!请点击每个评论上的 👍 或 👎,我将利用这些反馈来改进你的审查。
Original comment in English

Hey there - I've reviewed your changes - here's some feedback:

  • The combined if/else logic for version resolution is quite complex—consider splitting master‐push and tag‐release builds into separate workflows or jobs to simplify maintenance.
  • Relying on github.ref_type/ref_name can be fragile—parsing github.ref (refs/heads/… vs refs/tags/…) is more robust across different GitHub event types.
  • Using a static “test” tag for every master build overwrites previous images; consider appending a short commit SHA or build number for better traceability of test images.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The combined if/else logic for version resolution is quite complex—consider splitting master‐push and tag‐release builds into separate workflows or jobs to simplify maintenance.
- Relying on github.ref_type/ref_name can be fragile—parsing github.ref (refs/heads/… vs refs/tags/…) is more robust across different GitHub event types.
- Using a static “test” tag for every master build overwrites previous images; consider appending a short commit SHA or build number for better traceability of test images.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@LIghtJUNction
Copy link
Member

没事了,刚刚我没注意到

@magisk317
Copy link
Contributor Author

没事了,刚刚我没注意到

是的,标签和提交哈希都有,但是只用哈希的话,compose文件没办法引用,必须有个标签才行

ghcr.io/soulter/astrbot:test-latest
ghcr.io/soulter/astrbot:test-${{ steps.test-meta.outputs.short_sha }}

@LIghtJUNction
Copy link
Member

没事了,刚刚我没注意到

是的,标签和提交哈希都有,但是只用哈希的话,compose文件没办法引用,必须有个标签才行

ghcr.io/soulter/astrbot:test-latest
ghcr.io/soulter/astrbot:test-${{ steps.test-meta.outputs.short_sha }}

你那边测试情况如何

@magisk317
Copy link
Contributor Author

没事了,刚刚我没注意到

是的,标签和提交哈希都有,但是只用哈希的话,compose文件没办法引用,必须有个标签才行

ghcr.io/soulter/astrbot:test-latest
ghcr.io/soulter/astrbot:test-${{ steps.test-meta.outputs.short_sha }}

你那边测试情况如何

之前没试,试了一下发现问题出在奇怪的地方,我按默认默认配置DOCKER_HUB_PASSWORD走,提示我需要PAT, 18735206118
image

我改成PAT DOCKER_HUB_TOKEN ,又提示我需要密码,麻了, 18736600208
image

Updated README to enhance deployment instructions.
…cker-hub-failure

Make GHCR publishing optional in Docker workflow
@magisk317
Copy link
Contributor Author

@LIghtJUNction 基本搞定了,主要原因感觉是仓库owner的问题,在这边应该问题不大,后边几个关于owner的修改带不带都行,另外尝试了多次,提交的log看起来也比较难受,好在功能是正常的

=============================

image - web端功能正常: image

@LIghtJUNction
Copy link
Member

@LIghtJUNction 基本搞定了,主要原因感觉是仓库owner的问题,在这边应该问题不大,后边几个关于owner的修改带不带都行,另外尝试了多次,提交的log看起来也比较难受,好在功能是正常的

=============================

image - web端功能正常: image

辛苦你了

@LIghtJUNction
Copy link
Member

@Soulter 这个可以合吗

@Soulter
Copy link
Member

Soulter commented Oct 28, 2025

感觉没问题了

把 DOCKER_HUB_TOKEN 改回了 DOCKER_HUB_PASSWORD,和现在的一致

@LIghtJUNction LIghtJUNction requested a review from Copilot November 1, 2025 17:57
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the Docker CI/CD workflow to support separate test and release image builds, with improved handling of pre-release versions and multi-registry support.

Key Changes:

  • Split the workflow into two jobs: build-test-image (for master branch commits) and build-release-image (for tagged releases)
  • Enhanced registry support with conditional GHCR (GitHub Container Registry) integration
  • Improved metadata handling and tag generation for both test and release images

Reviewed Changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated 2 comments.

File Description
README.md Adds trailing whitespace to section header (cosmetic)
.github/workflows/docker-image.yml Splits workflow into test and release jobs with improved tagging, conditional GHCR support, and refactored metadata handling

Comment on lines +159 to +161
${{ steps.release-meta.outputs.is_prerelease == 'false' && env.HAS_GHCR_TOKEN == 'true' && format('ghcr.io/{0}/astrbot:latest', env.GHCR_OWNER) || '' }}
${{ format('{0}/astrbot:{1}', env.DOCKER_HUB_USERNAME, steps.release-meta.outputs.version) }}
${{ env.HAS_GHCR_TOKEN == 'true' && format('ghcr.io/{0}/astrbot:{1}', env.GHCR_OWNER, steps.release-meta.outputs.version) || '' }}
Copy link

Copilot AI Nov 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty string tags ('') will cause the Docker build to fail. When HAS_GHCR_TOKEN is false, these expressions produce empty tags which Docker cannot process. Consider filtering these tags conditionally in a separate step or using multi-line YAML syntax to conditionally include the lines.

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.

[Feature] 是否考虑docker镜像自动打包

3 participants