Skip to content

Commit

Permalink
feat(workflow): 更新 GitHub Actions 构建流程
Browse files Browse the repository at this point in the history
- 在 build.yml 中为 push 事件添加了 tags 触发条件。
- 增加了 workflow_dispatch 事件触发条件。
- 添加了提取标签名称的步骤,仅在标签以 'v' 开头时执行。
- 将构建和推送步骤拆分为 nightly 和 release 两个步骤,分别在推送到 main 分支和发布标签时执行。
- nightly 构建推送的镜像带有 nightly 标签。
- release 构建推送的镜像带有标签名称和 release 标签。
  • Loading branch information
sunist-c committed Aug 8, 2024
1 parent 2403f4e commit 829c3c4
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
push:
branches:
- main
tags:
- 'v*'
workflow_dispatch:

jobs:
build:
Expand All @@ -29,11 +32,29 @@ jobs:
id: extract_repo_name
run: echo "::set-output name=repo_name::${GITHUB_REPOSITORY##*/}"

- name: Build and push
- name: Extract tag name
if: startsWith(github.ref, 'refs/tags/v')
id: extract_tag_name
run: echo "::set-output name=tag_name::${GITHUB_REF#refs/tags/}"

- name: Build and push nightly
if: github.ref == 'refs/heads/main'
uses: docker/build-push-action@v2
with:
context: .
file: ./dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: ghcr.io/${{ github.repository_owner }}/${{ steps.extract_repo_name.outputs.repo_name }}:nightly

- name: Build and push release
if: startsWith(github.ref, 'refs/tags/v')
uses: docker/build-push-action@v2
with:
context: .
file: ./dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: ghcr.io/${{ github.repository_owner }}/${{ steps.extract_repo_name.outputs.repo_name }}:nightly
tags: |
ghcr.io/${{ github.repository_owner }}/${{ steps.extract_repo_name.outputs.repo_name }}:${{ steps.extract_tag_name.outputs.tag_name }}
ghcr.io/${{ github.repository_owner }}/${{ steps.extract_repo_name.outputs.repo_name }}:release

0 comments on commit 829c3c4

Please sign in to comment.