Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Publish Docker images with github action #1863

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

zclkkk
Copy link

@zclkkk zclkkk commented Feb 28, 2025

press the green button under action to build docker image & push to ghcr easily :)

Copy link
Contributor

sourcery-ai bot commented Feb 28, 2025

好的,这是将审查指南翻译成中文的结果:

Sourcery 审查者指南

此 Pull Request 引入了一个新的 GitHub Actions 工作流 (publish-docker.yml),该工作流自动化了构建 Docker 镜像并将其发布到 GitHub Container Registry (ghcr.io) 的过程。该工作流是手动触发的,包括登录到注册表、提取元数据、构建和推送镜像以及生成工件证明以增强安全性的步骤。

由于更改看起来很简单,不需要可视化表示,因此未生成图表。

文件级别更改

变更 详情 文件
实现了 GitHub Actions 工作流,用于构建 Docker 镜像并将其发布到 GitHub Container Registry (ghcr.io)。
  • 配置了手动触发的工作流。
  • 定义了容器注册表和镜像名称的环境变量。
  • 配置了在最新的 Ubuntu 版本上运行的作业。
  • 设置了 GITHUB_TOKEN 的权限,以允许读取内容、写入包和证明,以及使用 id-token。
  • 检出了存储库。
  • 使用 GitHub Actions 令牌登录到容器注册表。
  • 提取了 Docker 镜像的元数据(标签和标签)。
  • 构建 Docker 镜像并将其推送到 GitHub Packages。
  • 生成了镜像的工件证明,以增强供应链安全性。
.github/workflows/publish-docker.yml

提示和命令

与 Sourcery 互动

  • 触发新的审查: 在 Pull Request 上评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 从审查评论生成 GitHub issue: 通过回复审查评论,要求 Sourcery 从审查评论创建一个 issue。您也可以回复带有 @sourcery-ai issue 的审查评论以从中创建一个 issue。
  • 生成 Pull Request 标题: 在 Pull Request 标题中的任何位置写入 @sourcery-ai 以随时生成标题。您也可以在 Pull Request 上评论 @sourcery-ai title 以随时(重新)生成标题。
  • 生成 Pull Request 摘要: 在 Pull Request 正文中的任何位置写入 @sourcery-ai summary 以随时在您想要的位置生成 PR 摘要。您也可以在 Pull Request 上评论 @sourcery-ai summary 以随时(重新)生成摘要。
  • 生成审查者指南: 在 Pull Request 上评论 @sourcery-ai guide 以随时(重新)生成审查者指南。
  • 解决所有 Sourcery 评论: 在 Pull Request 上评论 @sourcery-ai resolve 以解决所有 Sourcery 评论。如果您已经解决了所有评论并且不想再看到它们,这将非常有用。
  • 驳回所有 Sourcery 审查: 在 Pull Request 上评论 @sourcery-ai dismiss 以驳回所有现有的 Sourcery 审查。如果您想重新开始新的审查,这将特别有用 - 不要忘记评论 @sourcery-ai review 以触发新的审查!
  • 为 issue 生成行动计划: 在 issue 上评论 @sourcery-ai plan 以为其生成行动计划。

自定义您的体验

访问您的 仪表板 以:

  • 启用或禁用审查功能,例如 Sourcery 生成的 Pull Request 摘要、审查者指南等。
  • 更改审查语言。
  • 添加、删除或编辑自定义审查说明。
  • 调整其他审查设置。

获得帮助

Original review guide in English

Reviewer's Guide by Sourcery

This pull request introduces a new GitHub Actions workflow (publish-docker.yml) that automates the process of building and publishing Docker images to the GitHub Container Registry (ghcr.io). The workflow is manually triggered and includes steps for logging into the registry, extracting metadata, building and pushing the image, and generating an artifact attestation for enhanced security.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Implemented a GitHub Actions workflow to build and publish Docker images to GitHub Container Registry (ghcr.io).
  • Configured the workflow to be triggered manually.
  • Defined environment variables for the container registry and image name.
  • Configured the job to run on the latest Ubuntu version.
  • Set permissions for the GITHUB_TOKEN to allow reading contents, writing packages and attestations, and using the id-token.
  • Checked out the repository.
  • Logged in to the container registry using the GitHub Actions token.
  • Extracted metadata (tags and labels) for the Docker image.
  • Built and pushed the Docker image to GitHub Packages.
  • Generated an artifact attestation for the image to enhance supply chain security.
.github/workflows/publish-docker.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

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.

@zclkkk - 我已经审查了你的更改 - 这里有一些反馈:

总体评论

  • 考虑为以 release 分支为目标的拉取请求添加触发器,以便在合并时自动构建镜像。
以下是我在审查期间查看的内容
  • 🟡 一般问题:发现 1 个问题
  • 🟢 安全性:一切看起来都很好
  • 🟢 测试:一切看起来都很好
  • 🟢 复杂性:一切看起来都很好
  • 🟢 文档:一切看起来都很好

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

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

Overall Comments:

  • Consider adding a trigger for pull requests targeting the release branch to automatically build images on merge.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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.

Comment on lines +43 to +50
- name: Build and push Docker image
id: push
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Copy link
Collaborator

@BalconyJH BalconyJH Mar 1, 2025

Choose a reason for hiding this comment

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

Consider using docker/setup-buildx-action@v3 to introduce the caching mechanism with actions/cache@v4 and updating the cache configuration in docker/build-push-action@v6 as per the official Docker documentation. Also, please remember to update the cache, including the "Move cache" step. If it's out of scope for this PR, we could explore it in a follow-up. What do you think?

uses: actions/checkout@v4
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
Copy link
Collaborator

Choose a reason for hiding this comment

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

We prefer locking the version to the major release in the action rather than using a SHA like docker/build-push-action@v6

@BalconyJH
Copy link
Collaborator

This PR looks great! We really appreciate the effort you've put into it. Looking forward to the update. Thanks!

@BalconyJH BalconyJH assigned BalconyJH and unassigned BalconyJH Mar 1, 2025
@BalconyJH BalconyJH added enhancement New feature or request P2 Important, but not urgent. ci Issues related to automated workflows, build pipelines, and CI tools. labels Mar 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci Issues related to automated workflows, build pipelines, and CI tools. enhancement New feature or request P2 Important, but not urgent.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants