Skip to content

Commit ae63c19

Browse files
committed
Use KO for building and pushing images
This uses the ko tool to build and push images to ghcr.io. Building with docker was crashing when compiling and is much slower than ko. Signed-off-by: Chmouel Boudjnah <[email protected]>
1 parent c6a7841 commit ae63c19

File tree

3 files changed

+50
-251
lines changed

3 files changed

+50
-251
lines changed

.github/workflows/container.yaml

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Create and publish a Docker image to ghcr on main and nightly with ko
2+
3+
on:
4+
push:
5+
paths:
6+
- "**.go"
7+
- "**.yaml"
8+
pull_request:
9+
paths:
10+
- "**.go"
11+
- "**.yaml"
12+
env:
13+
PLATFORMS: linux/amd64,linux/arm64,linux/ppc64le
14+
15+
jobs:
16+
build-and-push-image:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
20+
packages: write
21+
22+
concurrency:
23+
group: ${{ github.workflow }}-${{ github.ref }}
24+
cancel-in-progress: true
25+
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
30+
- name: Set up Go
31+
uses: actions/setup-go@v5
32+
with:
33+
go-version-file: "go.mod"
34+
35+
- uses: ko-build/[email protected]
36+
37+
- name: Build and push images
38+
shell: bash
39+
run: |
40+
set -x
41+
releaseBranchFormat='release-v'
42+
if [[ ${{ github.ref_name }} == ${releaseBranchFormat}* ]]; then
43+
tag="${${{ github.ref_name }}#*-}"
44+
else
45+
tag=$(echo ${{ github.ref_name }}|sed 's,/merge,,')
46+
fi
47+
48+
for image in ./cmd/*;do
49+
ko build -B -t "${tag}" --platform="${{ env.PLATFORMS }}" "${image}"
50+
done

.github/workflows/ghcr.yaml

-121
This file was deleted.

.github/workflows/multi-arch-ghcr-on-release.yaml

-130
This file was deleted.

0 commit comments

Comments
 (0)