From 4b078a0a4748d0084968a4cfb94649110cb96f9e Mon Sep 17 00:00:00 2001 From: Nitai Bezerra da Silva Date: Thu, 16 Mar 2023 20:00:43 -0300 Subject: [PATCH] ci(build_publish): publish also on tag Publishes another image under a tagged url. --- .../workflows/docker_build_and_publish.yml | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker_build_and_publish.yml b/.github/workflows/docker_build_and_publish.yml index 3e7aea5..9e08b68 100644 --- a/.github/workflows/docker_build_and_publish.yml +++ b/.github/workflows/docker_build_and_publish.yml @@ -2,9 +2,8 @@ name: Build and Publish Docker Image on: push: - branches: - - main - - build_publish_image + tags: + - '*' jobs: build_and_push: @@ -23,9 +22,20 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push Docker image + - name: Extract tag name + shell: bash + run: echo "TAG_NAME=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_ENV + + - name: Build and push Docker image with tag + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: ghcr.io/${{ github.repository }}:${{ env.TAG_NAME }} + + - name: Build and push Docker image with latest tag uses: docker/build-push-action@v2 with: context: . push: true - tags: ghcr.io/${{ github.repository_owner }}/ro-dou:latest + tags: ghcr.io/${{ github.repository }}:latest