File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 99 push_to_registry :
1010 name : Build and push Docker image to Docker Hub
1111 runs-on : ubuntu-22.04
12- if : startsWith(github.event.ref_name, 'release-')
1312
1413 steps :
1514 - name : Check out the repo with the latest code
@@ -29,14 +28,21 @@ jobs:
2928 run : |
3029 git fetch --prune --unshallow
3130 TAG=$(git describe --tags --abbrev=0)
32- echo $TAG
3331 echo "TAG=$TAG" >> $GITHUB_ENV
3432
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+
3540 - name : Build and push Docker image
41+ if : env.TAG_EXISTS != '200'
3642 uses : docker/build-push-action@v6
3743 with :
3844 context : .
3945 push : true
4046 tags : |
4147 ${{ 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