Skip to content

Commit 3a38277

Browse files
committed
Fix build on tag creation
1 parent da76cd5 commit 3a38277

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

.github/workflows/deploy.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Test & build Docker image
33
on:
44
push:
55
branches: [ master ]
6+
tags: ['*']
67
pull_request:
78

89
env:
@@ -41,7 +42,6 @@ jobs:
4142
sarif_file: 'trivy-results.sarif'
4243

4344
- name: Login to Docker Hub
44-
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
4545
uses: docker/login-action@v1
4646
with:
4747
username: ${{ secrets.DOCKERHUB_USERNAME }}
@@ -52,7 +52,12 @@ jobs:
5252
run: |-
5353
docker push $IMAGE_NAME:latest
5454
55+
- name: Set tag in environment
56+
if: contains(github.ref, 'refs/tags/')
57+
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
58+
5559
- name: Push tagged image
56-
if: contains(github.ref, 'refs/tags/v')
60+
if: contains(github.ref, 'refs/tags/')
5761
run: |-
58-
docker push $IMAGE_NAME:$GITHUB_TAG
62+
docker tag $IMAGE_NAME:${{ github.sha }} $IMAGE_NAME:$RELEASE_VERSION
63+
docker push $IMAGE_NAME:$RELEASE_VERSION

0 commit comments

Comments
 (0)