1
1
name : Build docker images
2
2
3
- env :
4
- DOCKER_BASE_NAME : ' ghcr.io/${{ github.repository_owner }}/cert-manager-webhook-dnsimple'
5
-
6
3
on :
7
4
workflow_call :
8
5
inputs :
@@ -20,30 +17,32 @@ jobs:
20
17
- name : Checkout code
21
18
uses : actions/checkout@v4
22
19
23
- - name : Set up QEMU
24
- uses : docker/setup-qemu-action@v3
25
-
26
- - name : Set up Docker Buildx
27
- uses : docker/setup-buildx-action@v3
28
20
29
- - name : Login to GHCR
30
- uses : docker/login-action@v3
21
+ - name : Setup Go
22
+ uses : actions/setup-go@v5
31
23
with :
32
- registry : ghcr.io
33
- password : ${{ secrets.GITHUB_TOKEN }}
34
- username : ${{ github.repository_owner }}
35
-
36
- - name : Format tags
37
- id : format-tags
38
- # prepends DOCKER_BASE_NAME to every entry in the string ${{ inputs.tags }}
24
+ go-version-file : src/go.mod
25
+ cache-dependency-path : src/go.sum
26
+
27
+
28
+ - name : Get go dependencies
39
29
run : |
40
- echo "TAGS=$(printf '${{ env.DOCKER_BASE_NAME }}:%s,' ${{ inputs.tags }})" >> $GITHUB_OUTPUT
30
+ cd src
31
+ go mod download
41
32
42
- - name : Build and push Docker image
43
- uses : docker/build-push-action@v5
44
- with :
45
- context : .
46
- file : ./Dockerfile
47
- platforms : linux/amd64,linux/arm64
48
- push : true
49
- tags : ${{ steps.format-tags.outputs.TAGS }}
33
+
34
+ - name : Setup ko
35
+ # KO is a tool for building go container images https://ko.build/
36
+
37
+ # KO is configured to use GHCR as the registry
38
+
39
+
40
+ - name : Format tags with a comma
41
+ id : format-tags
42
+ run : echo "TAGS=$(echo ${{ inputs.tags }} | tr ' ' ',')" >> $GITHUB_OUTPUT
43
+
44
+
45
+ - name : Build images
46
+ run : |
47
+ cd src
48
+ ko build --tags="${{ steps.format-tags.outputs.TAGS }}" --platform=linux/amd64,linux/arm64 --bare --sbom=none
0 commit comments