44 push :
55 branches :
66 - 3.x
7- # Build and push Docker images *only* for releases.
87 release :
9- types : [published] # , created, edited
8+ types : [published]
109
1110jobs :
1211 push_to_registry :
1312 name : Build and push Docker image to Docker Hub
1413 runs-on : ubuntu-22.04
1514
1615 steps :
17- - name : Check out the repo with latest code
16+ - name : Check out the repo with the latest code
1817 uses : actions/checkout@v4
19- - name : Push latest to Docker Hub
20- uses : docker/build-push-action@v4 # Info: https://github.com/docker/build-push-action/tree/releases/v1#tags
18+
19+ - name : Set up Docker Buildx
20+ uses : docker/setup-buildx-action@v3
21+
22+ - name : Login to Docker Hub
23+ uses : docker/login-action@v3
2124 with :
2225 username : ${{ secrets.DOCKERHUB_USERNAME }}
2326 password : ${{ secrets.DOCKERHUB_PASSWORD }}
24- repository : ${{ secrets.DOCKERHUB_REPOSITORY }}
25- tag_with_ref : true # Info: https://github.com/docker/build-push-action/tree/releases/v1#tag_with_ref
26- tag_with_sha : true # Info: https://github.com/docker/build-push-action/tree/releases/v1#tag_with_sha
27- tags : latest
2827
29- - name : ' Get the current tag'
28+ - name : Get the current tag
3029 id : currentTag
31- uses : actions/checkout@v4
32- - run : git fetch --prune --unshallow && TAG=$(git describe --tags --abbrev=0) && echo $TAG && echo "TAG="$TAG >> "$GITHUB_ENV"
33- - name : Check out the repo with tag
34- uses : actions/checkout@v4
35- with :
36- ref : ${{ env.TAG }}
30+ run : git fetch --prune --unshallow && TAG=$(git describe --tags --abbrev=0) && echo $TAG && echo "TAG="$TAG >> "$GITHUB_ENV"
3731
38- - name : Push current tag to Docker Hub
39- uses : docker/build-push-action@v1 # Info: https://github.com/docker/build-push-action/tree/releases/v1#tags
32+ - name : Build and push Docker image
33+ uses : docker/build-push-action@v6
4034 with :
41- username : ${{ secrets.DOCKERHUB_USERNAME }}
42- password : ${{ secrets.DOCKERHUB_PASSWORD }}
43- repository : ${{ secrets.DOCKERHUB_REPOSITORY }}
44- tag_with_ref : true # Info: https://github.com/docker/build-push-action/tree/releases/v1#tag_with_ref
45- tag_with_sha : true # Info: https://github.com/docker/build-push-action/tree/releases/v1#tag_with_sha
46- tags : ${{ env.TAG }}
35+ context : .
36+ push : true
37+ tags : |
38+ ${{ secrets.DOCKERHUB_REPOSITORY }}:latest
39+ ${{ secrets.DOCKERHUB_REPOSITORY }}:${{ env.TAG }}
0 commit comments