1
+ name : ' Build & Push Docker'
2
+
3
+ inputs :
4
+ compose-version :
5
+ description : ' Docker Compose version'
6
+ default : 2.6.0
7
+ registry :
8
+ description : ' Docker registry service'
9
+ default : ghcr.io
10
+ username :
11
+ description : ' Username for https://ghcr.io'
12
+ required : true
13
+ password :
14
+ description : ' Password for https://ghcr.io'
15
+ required : true
16
+ image :
17
+ description : ' Image name with provider url'
18
+ required : true
19
+ dockerfile :
20
+ description : ' Path to the Dockerfile'
21
+ required : true
22
+ context :
23
+ description : ' Path to the Context'
24
+ default : .
25
+ required : true
26
+ build-args :
27
+ description : ' List of build-time variables'
28
+ required : false
29
+
30
+ outputs :
31
+ image :
32
+ description : ' Image url'
33
+ value : ${{ steps.imageOuput.outputs.imageUrl }}
34
+ imageid :
35
+ description : ' Image ID'
36
+ value : ${{ steps.publish.outputs.imageId }}
37
+ digest :
38
+ description : ' Image digest'
39
+ value : ${{ steps.publish.outputs.digest }}
40
+ metadata :
41
+ description : ' Build result metadata'
42
+ value : ${{ steps.publish.outputs.metadata }}
43
+
44
+ runs :
45
+ using : ' composite'
46
+ steps :
47
+ - name : Log in to the ghcr.io registry
48
+ uses : docker/login-action@v2
49
+ with :
50
+ registry : ${{ inputs.registry }}
51
+ username : ${{ inputs.username }}
52
+ password : ${{ inputs.password }}
53
+
54
+ - name : Docker meta
55
+ id : meta
56
+ uses : docker/metadata-action@v3
57
+ with :
58
+ images : |
59
+ ${{ inputs.image }}
60
+ tags : |
61
+ type=ref,event=branch
62
+ type=sha,prefix=
63
+ type=semver,pattern={{raw}}
64
+
65
+ - name : Set up Docker Buildx
66
+ uses : docker/setup-buildx-action@v1
67
+
68
+ - name : Build and push the image to ghcr.io
69
+ uses : docker/build-push-action@v4
70
+ id : publish
71
+ with :
72
+ context : ${{ inputs.context }}
73
+ file : ${{ inputs.dockerfile }}
74
+ push : true
75
+ tags : ${{ steps.meta.outputs.tags }}
76
+ labels : ${{ steps.meta.outputs.labels }}
77
+ build-args : ${{ inputs.build-args }}
78
+ cache-from : type=registry,ref=${{ inputs.image }}-cache
79
+ cache-to : type=registry,ref=${{ inputs.image }}-cache,mode=max
80
+ - id : imageOuput
81
+ shell : bash
82
+ run : |
83
+ echo "imageUrl=${{ fromJSON(steps.publish.outputs.metadata)['image.name'] }}" >> $GITHUB_OUTPUT
0 commit comments