File tree 1 file changed +9
-3
lines changed
1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 9
9
push_to_registry :
10
10
name : Build and push Docker image to Docker Hub
11
11
runs-on : ubuntu-22.04
12
- if : startsWith(github.event.ref_name, 'release-')
13
12
14
13
steps :
15
14
- name : Check out the repo with the latest code
@@ -29,14 +28,21 @@ jobs:
29
28
run : |
30
29
git fetch --prune --unshallow
31
30
TAG=$(git describe --tags --abbrev=0)
32
- echo $TAG
33
31
echo "TAG=$TAG" >> $GITHUB_ENV
34
32
33
+ - name : Check if Docker tag exists
34
+ id : tagCheck
35
+ run : |
36
+ REPO="${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPOSITORY }}"
37
+ TAG_EXISTS=$(curl -s -o /dev/null -w "%{http_code}" "https://hub.docker.com/v2/repositories/${REPO}/tags/${TAG}/")
38
+ echo "TAG_EXISTS=$TAG_EXISTS" >> $GITHUB_ENV
39
+
35
40
- name : Build and push Docker image
41
+ if : env.TAG_EXISTS != '200'
36
42
uses : docker/build-push-action@v6
37
43
with :
38
44
context : .
39
45
push : true
40
46
tags : |
41
47
${{ secrets.DOCKERHUB_REPOSITORY }}:latest
42
- ${{ secrets.DOCKERHUB_REPOSITORY }}:${{ env.TAG }}
48
+ ${{ secrets.DOCKERHUB_REPOSITORY }}:${{ env.TAG }}
You can’t perform that action at this time.
0 commit comments