4
4
push :
5
5
branches :
6
6
- 3.x
7
- # Build and push Docker images *only* for releases.
8
7
release :
9
- types : [published] # , created, edited
8
+ types : [published]
10
9
11
10
jobs :
12
11
push_to_registry :
13
12
name : Build and push Docker image to Docker Hub
14
13
runs-on : ubuntu-22.04
15
14
16
15
steps :
17
- - name : Check out the repo with latest code
16
+ - name : Check out the repo with the latest code
18
17
uses : actions/checkout@v4
19
- - name : Push latest to Docker Hub
20
- uses : docker/build-push-action@v6 # 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@v2
21
+
22
+ - name : Login to Docker Hub
23
+ uses : docker/login-action@v2
21
24
with :
22
25
username : ${{ secrets.DOCKERHUB_USERNAME }}
23
26
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
28
27
29
- - name : ' Get the current tag'
28
+ - name : Get the current tag
30
29
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 : echo "TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
37
31
38
- - name : Push current tag to Docker Hub
39
- uses : docker/build-push-action@v6 # 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
40
34
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