Fix build on tag creation

multi-arch-builds
Tim de Pater 2021-09-25 07:09:52 +02:00
parent da76cd5f6b
commit 3a38277dc8
No known key found for this signature in database
GPG Key ID: BFE5D809439C9723
1 changed files with 8 additions and 3 deletions

View File

@ -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