diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index b1ac50e..3329682 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -3,6 +3,7 @@ name: Test & build Docker image on: push: branches: [ master ] + tags: ['*'] pull_request: env: @@ -41,7 +42,6 @@ jobs: sarif_file: 'trivy-results.sarif' - name: Login to Docker Hub - if: github.ref == 'refs/heads/master' && github.event_name == 'push' uses: docker/login-action@v1 with: username: ${{ secrets.DOCKERHUB_USERNAME }} @@ -52,7 +52,12 @@ jobs: run: |- docker push $IMAGE_NAME:latest + - name: Set tag in environment + if: contains(github.ref, 'refs/tags/') + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + - name: Push tagged image - if: contains(github.ref, 'refs/tags/v') + if: contains(github.ref, 'refs/tags/') run: |- - docker push $IMAGE_NAME:$GITHUB_TAG + docker tag $IMAGE_NAME:${{ github.sha }} $IMAGE_NAME:$RELEASE_VERSION + docker push $IMAGE_NAME:$RELEASE_VERSION