From 85a1298ed0c953e557a1d444c5ca4e2ddb1721da Mon Sep 17 00:00:00 2001 From: ShiYu Date: Sat, 24 May 2025 10:39:16 +0800 Subject: [PATCH] ci(docker): update workflow to build and push Docker images --- .github/workflows/docker.yml | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index a4f7833..12254df 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -2,14 +2,13 @@ name: Build and Push Docker image on: push: - branches: - - '**' + tags: + - 'v*.*.*' + workflow_dispatch: jobs: build-and-push: runs-on: ubuntu-latest - if: startsWith(github.event.head_commit.message, 'pub(docker)') - permissions: contents: read packages: write @@ -21,6 +20,16 @@ jobs: - name: Lowercase repo name run: echo "REPO_LC=${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV + - name: Set up Docker tags + id: meta + run: | + if [[ $GITHUB_REF == refs/tags/* ]]; then + VERSION=${GITHUB_REF#refs/tags/} + echo "DOCKER_TAGS=ghcr.io/${REPO_LC}:${VERSION},ghcr.io/${REPO_LC}:latest" >> $GITHUB_ENV + else + echo "DOCKER_TAGS=ghcr.io/${REPO_LC}:dev" >> $GITHUB_ENV + fi + - name: Log in to GitHub Container Registry uses: docker/login-action@v3 with: @@ -33,4 +42,4 @@ jobs: with: context: . push: true - tags: ghcr.io/${{ env.REPO_LC }}:dev \ No newline at end of file + tags: ${{ env.DOCKER_TAGS }} \ No newline at end of file