From 9d7050cfc059e2ca9884dc5fe2672fe4a1b4a5fc Mon Sep 17 00:00:00 2001 From: Emmanuel Paul Date: Mon, 16 Sep 2024 20:13:24 -0400 Subject: [PATCH] build on tags --- .github/workflows/docker-build-and-push.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker-build-and-push.yml b/.github/workflows/docker-build-and-push.yml index 3d15862..262f536 100644 --- a/.github/workflows/docker-build-and-push.yml +++ b/.github/workflows/docker-build-and-push.yml @@ -2,8 +2,8 @@ name: Build and Push Docker Image on: push: - branches: - - master + tags: + - 'v*.*.*' jobs: build: @@ -20,11 +20,15 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GHCR_TOKEN }} + - name: Extract tag name + id: extract_tag + run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + - name: Build Docker image run: | - docker build -t flask-json-ui:latest -f Dockerfile . + docker build -t flask-json-ui:${{ env.TAG_NAME }} -f Dockerfile . - name: Tag and push Docker image run: | - docker tag flask-json-ui:latest ghcr.io/networkpaul/json-route-app/flask-json-ui:latest - docker push ghcr.io/networkpaul/json-route-app/flask-json-ui:latest + docker tag flask-json-ui:${{ env.TAG_NAME }} ghcr.io/networkpaul/json-route-app/flask-json-ui:${{ env.TAG_NAME }} + docker push ghcr.io/networkpaul/json-route-app/flask-json-ui:${{ env.TAG_NAME }}