Skip to content

Commit 8cb9ff0

Browse files
Build and push container images on main:
We were building and pushing images from main before moving to goreleaser. This get this functionality back. Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
1 parent 73e3fa7 commit 8cb9ff0

File tree

4 files changed

+43
-5
lines changed

4 files changed

+43
-5
lines changed

.github/workflows/ci.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,39 @@ jobs:
6767

6868
- name: Build
6969
run: make build-image
70+
71+
build-push-image:
72+
name: Build and push image
73+
runs-on: ubuntu-latest
74+
if: ${{ github.ref == 'refs/heads/main' }}
75+
needs:
76+
- validate
77+
- codespell
78+
- build
79+
steps:
80+
- name: Checkout code
81+
uses: actions/checkout@v5
82+
83+
- uses: actions/setup-go@v6
84+
with:
85+
go-version: "${{ env.GO_VERSION }}"
86+
cache: true
87+
88+
- name: Set up QEMU
89+
uses: docker/setup-qemu-action@v3
90+
91+
- name: Set up Docker Buildx
92+
uses: docker/setup-buildx-action@v3
93+
94+
- name: Log in to the Container registry
95+
uses: docker/login-action@v3
96+
with:
97+
registry: ${{ env.REGISTRY }}
98+
username: ${{ github.actor }}
99+
password: ${{ secrets.GITHUB_TOKEN }}
100+
101+
- name: Build and push image
102+
run: make build-image-push
103+
env:
104+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
105+
IS_RELEASE: false

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
password: ${{ secrets.GITHUB_TOKEN }}
4242

4343
- name: Build and push image
44-
run: make image-build-push
44+
run: make build-image-push
4545
env:
4646
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4747

.goreleaser.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ env:
44
- REGISTRY={{ if index .Env "REGISTRY" }}{{ .Env.REGISTRY }}{{ else }}ghcr.io{{ end }}
55
- IMAGE_NAME={{ if index .Env "IMAGE_NAME" }}{{ .Env.IMAGE_NAME }}{{ else }}tinkerbell/cluster-api-provider-tinkerbell{{ end }}
66
- BINARY=capt
7+
- IS_RELEASE={{ if index .Env "IS_RELEASE" }}{{ .Env.IS_RELEASE }}{{ else }}true{{ end }}
78

89
before:
910
hooks:
@@ -36,8 +37,9 @@ dockers_v2:
3637
- images:
3738
- "{{ .Env.REGISTRY }}/{{ .Env.IMAGE_NAME }}"
3839
tags:
39-
- "v{{ .Version }}"
40-
- "{{ if not .IsNightly }}latest{{ end }}"
40+
- '{{ if eq .Env.IS_RELEASE "true" }}v{{ .Version }}{{ end }}'
41+
- '{{ if not .IsNightly }}latest{{ end }}'
42+
- '{{ if eq .Branch "main" }}sha-{{ .ShortCommit }}{{ end }}'
4143
labels:
4244
"org.opencontainers.image.created": "{{.Date}}"
4345
"org.opencontainers.image.name": "{{.ProjectName}}"

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ build: generate $(GORELEASER) ## Build the CAPT binary
142142
build-image: $(GORELEASER) ## Build the container image
143143
${GORELEASER} release --snapshot --clean --verbose
144144

145-
.PHONY: image-build-push
146-
image-build-push: $(GORELEASER) ## Build and push the container image
145+
.PHONY: build-image-push
146+
build-image-push: $(GORELEASER) ## Build and push the container image
147147
${GORELEASER} release --clean --verbose
148148

149149
## --------------------------------------

0 commit comments

Comments
 (0)