Skip to content

Commit 87aa8ec

Browse files
committed
ci: build head docker images on changes in main
Enables a docker build step on every commit to the main branch. Each docker image will have a tag `head-<architecture>`. E.g.: vcluster-oss:head-arm64v8 or vcluster-oss:head-amd64
1 parent bde1620 commit 87aa8ec

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

.github/workflows/update-cache.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ jobs:
2323

2424
- run: git fetch --force --tags
2525

26+
- name: Set branch name
27+
run: echo "CI_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
28+
2629
- name: Set up Go
2730
uses: actions/setup-go@v5
2831
id: cache
@@ -40,8 +43,8 @@ jobs:
4043
run: |
4144
set -x
4245
# Build syncer
43-
TELEMETRY_PRIVATE_KEY="" goreleaser build --single-target --snapshot --id vcluster --clean --output ./vcluster
46+
CI_BRANCH="${CI_BRANCH}" TELEMETRY_PRIVATE_KEY="" goreleaser build --single-target --snapshot --id vcluster --clean --output ./vcluster
4447
# Build cli
45-
TELEMETRY_PRIVATE_KEY="" goreleaser build --single-target --snapshot --id vcluster-cli --clean --output ./vcluster
48+
CI_BRANCH="${CI_BRANCH}" TELEMETRY_PRIVATE_KEY="" goreleaser build --single-target --snapshot --id vcluster-cli --clean --output ./vcluster
4649
# Build tests for cache
4750
go test -mod=vendor -test.v -c ./test/e2e

.goreleaser.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ before:
1010
- '{{ if not .IsSnapshot }}just generate-vcluster-latest-images {{ .Version }}{{ else }}echo "Skipping generate-vcluster-latest-images"{{ end }}'
1111
- '{{ if not .IsSnapshot }}just generate-vcluster-optional-images{{ else }}echo "Skipping generate-vcluster-optional-images"{{ end }}'
1212
- '{{ if not .IsSnapshot }}just generate-matrix-specific-images {{ .Version }}{{ else }}echo "Skipping generate-matrix-specific-images"{{ end }}'
13+
- '{{ if or .IsSnapshot (eq .Env.CI_BRANCH "main") }}echo "Building head images for main branch commit $(git rev-parse --short HEAD)"{{ end }}'
1314

1415
source:
1516
format: tar.gz
@@ -182,6 +183,8 @@ dockers:
182183
- '{{ if eq .Prerelease "" }}ghcr.io/loft-sh/vcluster-oss:latest-amd64{{ end }}'
183184
- '{{ if eq .Prerelease "" }}ghcr.io/loft-sh/vcluster-oss:{{ .Major }}-amd64{{ end }}'
184185
- '{{ if eq .Prerelease "" }}ghcr.io/loft-sh/vcluster-oss:{{ .Major }}.{{ .Minor }}-amd64{{ end }}'
186+
# Add head tag for main branch
187+
- '{{ if or .IsSnapshot (eq .Env.CI_BRANCH "main") }}ghcr.io/loft-sh/vcluster-oss:head-amd64{{ end }}'
185188
use: buildx
186189
dockerfile: Dockerfile.release
187190
ids:
@@ -199,6 +202,8 @@ dockers:
199202
- '{{ if eq .Prerelease "" }}ghcr.io/loft-sh/vcluster-oss:latest-arm64v8{{ end }}'
200203
- '{{ if eq .Prerelease "" }}ghcr.io/loft-sh/vcluster-oss:{{ .Major }}-arm64v8{{ end }}'
201204
- '{{ if eq .Prerelease "" }}ghcr.io/loft-sh/vcluster-oss:{{ .Major }}.{{ .Minor }}-arm64v8{{ end }}'
205+
# Add head tag for main branch
206+
- '{{ if or .IsSnapshot (eq .Env.CI_BRANCH "main") }}ghcr.io/loft-sh/vcluster-oss:head-arm64v8{{ end }}'
202207
use: buildx
203208
goarch: arm64
204209
dockerfile: Dockerfile.release
@@ -303,6 +308,21 @@ docker_manifests:
303308
- loftsh/vcluster-cli:{{ .Major }}-arm64v8
304309
skip_push: auto
305310

311+
# --- Head multi arch manifest ---
312+
- name_template: ghcr.io/loft-sh/vcluster-oss:head
313+
image_templates:
314+
- ghcr.io/loft-sh/vcluster-oss:head-amd64
315+
- ghcr.io/loft-sh/vcluster-oss:head-arm64v8
316+
# Only push on main branch
317+
skip_push: '{{ and (ne .Env.CI_BRANCH "main") (not .IsSnapshot) }}'
318+
319+
# --- Head multi arch manifest for vcluster-cli ---
320+
- name_template: ghcr.io/loft-sh/vcluster-cli:head
321+
image_templates:
322+
- ghcr.io/loft-sh/vcluster-cli:head-amd64
323+
- ghcr.io/loft-sh/vcluster-cli:head-arm64v8
324+
# Only push on main branch
325+
skip_push: '{{ and (ne .Env.CI_BRANCH "main") (not .IsSnapshot) }}'
306326
docker_signs:
307327
- cmd: cosign
308328
env:

0 commit comments

Comments
 (0)