@@ -7,6 +7,7 @@ name: Build Docker image & push
7
7
on :
8
8
release :
9
9
types : [published]
10
+ pull_request :
10
11
11
12
jobs :
12
13
build-docker-image :
@@ -17,24 +18,31 @@ jobs:
17
18
18
19
steps :
19
20
- name : Check out code into the Go module directory
20
- uses : actions/checkout@v2
21
+ uses : actions/checkout@v4
21
22
22
- - name : Get the version
23
- id : get_version
24
- run : echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}
25
-
26
- - name : Build image
27
- run : |
28
- TAG_VERSION=${{ steps.get_version.outputs.VERSION }}
29
- cd ${GITHUB_WORKSPACE} && docker build -t "${REGISTRY_HOSTNAME}/${IMAGE_NODE}:${TAG_VERSION}" -f ./docker/Dockerfile .
30
-
31
- - name : Login to Docker Hub
32
- uses : docker/login-action@v2
23
+ - name : Extract metadata (tags, labels) for Docker
24
+ id : meta
25
+ uses : docker/metadata-action@v5
26
+ with :
27
+ images : ${{ env.REGISTRY_HOSTNAME }}/${{ env.IMAGE_NODE }}
28
+
29
+ - name : Set up Docker Buildx
30
+ uses : docker/setup-buildx-action@v3
31
+
32
+ - name : Log into Docker Hub
33
+ if : github.event_name != 'pull_request'
34
+ uses : docker/login-action@v3
33
35
with :
34
36
username : ${{ secrets.DOCKERHUB_USERNAME }}
35
37
password : ${{ secrets.DOCKERHUB_TOKEN }}
36
38
37
- - name : Push image
38
- run : |
39
- TAG_VERSION=${{ steps.get_version.outputs.VERSION }}
40
- docker push "${REGISTRY_HOSTNAME}/${IMAGE_NODE}:${TAG_VERSION}"
39
+ - name : Build and push image to Docker Hub
40
+ id : push
41
+ uses : docker/build-push-action@v6
42
+ with :
43
+ context : .
44
+ file : ./docker/Dockerfile
45
+ platforms : linux/amd64,linux/arm64
46
+ push : ${{ github.event_name != 'pull_request' }}
47
+ tags : ${{ steps.meta.outputs.tags }}
48
+ labels : ${{ steps.meta.outputs.labels }}
0 commit comments