Skip to content

Commit 1f64cdf

Browse files
authored
use ko to build images (#34)
1 parent 97de643 commit 1f64cdf

File tree

5 files changed

+28
-54
lines changed

5 files changed

+28
-54
lines changed

.github/workflows/build-images.yaml

+25-26
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
name: Build docker images
22

3-
env:
4-
DOCKER_BASE_NAME: 'ghcr.io/${{ github.repository_owner }}/cert-manager-webhook-dnsimple'
5-
63
on:
74
workflow_call:
85
inputs:
@@ -20,30 +17,32 @@ jobs:
2017
- name: Checkout code
2118
uses: actions/checkout@v4
2219

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
2820

29-
- name: Login to GHCR
30-
uses: docker/login-action@v3
21+
- name: Setup Go
22+
uses: actions/setup-go@v5
3123
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
3929
run: |
40-
echo "TAGS=$(printf '${{ env.DOCKER_BASE_NAME }}:%s,' ${{ inputs.tags }})" >> $GITHUB_OUTPUT
30+
cd src
31+
go mod download
4132
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+
uses: ko-build/[email protected]
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

.github/workflows/workflow_full-test-suite.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
name: Build Docker image
2020
uses: ./.github/workflows/build-images.yaml
2121
with:
22-
tags: >
22+
tags: >-
2323
commit-${{ github.sha }}
2424
latest
2525
needs: code-test

.github/workflows/workflow_tagged-build.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
name: Build tagged Docker image
1111
uses: ./.github/workflows/build-images.yaml
1212
with:
13-
tags: >
13+
tags: >-
1414
${{ github.ref_name }}
1515
commit-${{ github.sha }}
1616
latest

Dockerfile

-25
This file was deleted.

src/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module github.com/neoskop/cert-manager-webhook-dnsimple
1+
module github.com/puzzle/cert-manager-webhook-dnsimple
22

33
go 1.22
44

0 commit comments

Comments
 (0)