From f6f437b17a25c2b97d66c94b241b2f7eab0576e2 Mon Sep 17 00:00:00 2001 From: sakkiii Date: Thu, 9 Dec 2021 02:32:43 +0530 Subject: [PATCH] version tag on docker hub (#187) * version tag on docker hub * resolve name collision * master branch added for latest tag * prettier-ignore fix --- .github/workflows/docker-release.yml | 31 +++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml index 85752a7..a9e6046 100644 --- a/.github/workflows/docker-release.yml +++ b/.github/workflows/docker-release.yml @@ -2,8 +2,14 @@ name: Create docker image(s) and push to docker hub on: push: - tags: - - '[0-9]+\.[0-9]+\.[0-9]+' + # Sequence of patterns matched against refs/heads + # prettier-ignore + branches: + # Push events on master branch + - master + # Sequence of patterns matched against refs/tags + tags: + - '[0-9]+\.[0-9]+\.[0-9]+' # Push events to 0.X.X tag jobs: docker: @@ -21,10 +27,25 @@ jobs: with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push + - name: Calculate docker image tag + id: set-tag + run: | + case "${GITHUB_REF}" in + refs/heads/master|refs/heads/main) + tag=latest + ;; + refs/tags/*) + tag=${GITHUB_REF#refs/tags/} + ;; + *) + tag=${GITHUB_SHA} + ;; + esac + echo "::set-output name=tag::$tag" + - name: Build and Push Tag uses: docker/build-push-action@v2 with: context: . - platforms: linux/amd64,linux/arm64 push: true - tags: awesometechnologies/synapse-admin:latest + tags: "awesometechnologies/synapse-admin:${{ steps.set-tag.outputs.tag }}" + platforms: linux/amd64,linux/arm64