From 861795fc3826f557a154ef266806693dd0d71aad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjarne=20=C3=98verli?= Date: Fri, 19 Aug 2022 10:59:35 +0200 Subject: [PATCH] feat: push the docker image to dockerhub as a tag as well This will prevent people from just using latest, and potentially breaking their application. Anything up to version 2.0.0 has been pushed as latest, so it will break anything beforet his --- .github/workflows/publish_docker_image.yaml | 46 +++++++++++++-------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/.github/workflows/publish_docker_image.yaml b/.github/workflows/publish_docker_image.yaml index 48db8347..639c021d 100644 --- a/.github/workflows/publish_docker_image.yaml +++ b/.github/workflows/publish_docker_image.yaml @@ -1,21 +1,31 @@ name: Publish Docker image on: - release: - types: [published] + release: + types: [published] jobs: - push_to_registry: - name: Push Docker image to Docker Hub - runs-on: ubuntu-latest - steps: - - name: Check out the repo - uses: actions/checkout@v2 - - name: Log in to Docker Hub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - name: Push to Docker Hub - uses: docker/build-push-action@v2 - with: - push: true - tags: hemmeligapp/hemmelig:latest \ No newline at end of file + push_to_registry: + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v2 + - name: Log in to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: Get latest git tag + id: latest_tag + uses: 'WyriHaximus/github-action-get-previous-tag@v1' + with: + fallback: no-tag + - name: Push to Docker Hub + uses: docker/build-push-action@v2 + with: + push: true + tags: hemmeligapp/hemmelig:latest + - name: Push to Docker Hub + uses: docker/build-push-action@v2 + with: + push: true + tags: hemmeligapp/hemmelig:${{ steps.latest_tag.outputs.tag }}