Skip to content

Commit f19169f

Browse files
authored
Merge pull request #1939 from rabbitmq/ci/ghcr
Use github packages for our container image
2 parents adac80b + 2e94c8c commit f19169f

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

.github/workflows/build-test-publish.yml

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313
branches: [ "main" ]
1414

1515
env:
16-
GO_VERSION: ~1.24
16+
GO_VERSION: 'stable'
1717
# Taken from https://github.com/kubernetes-sigs/kind/releases/tag/v0.18.0
1818
# The image here should be listed under 'Images built for this release' for the version of kind in go.mod
1919
KIND_NODE_IMAGE: "kindest/node:v1.32.0"
@@ -120,11 +120,13 @@ jobs:
120120
permissions:
121121
contents: 'write'
122122
id-token: 'write'
123+
packages: 'write'
123124
steps:
124125
- name: Checkout
125126
uses: actions/checkout@v5
126127

127128
- name: Install Go
129+
id: set-go
128130
uses: actions/setup-go@v5
129131
with:
130132
go-version: ${{ env.GO_VERSION }}
@@ -138,6 +140,7 @@ jobs:
138140
images: |
139141
rabbitmqoperator/cluster-operator
140142
quay.io/rabbitmqoperator/cluster-operator
143+
ghcr.io/rabbitmq/cluster-operator
141144
# generate Docker tags based on the following events/attributes
142145
tags: |
143146
type=sha
@@ -151,20 +154,28 @@ jobs:
151154
uses: docker/setup-buildx-action@v3
152155

153156
- name: Login to Docker Hub
154-
if: github.event_name != 'pull_request'
157+
if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/v') }}
155158
uses: docker/login-action@v3
156159
with:
157160
username: ${{ secrets.DOCKERHUB_USERNAME }}
158161
password: ${{ secrets.DOCKERHUB_TOKEN }}
159162

160163
- name: Login to Quay.io
161-
if: github.event_name != 'pull_request'
164+
if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/v') }}
162165
uses: docker/login-action@v3
163166
with:
164167
registry: quay.io
165168
username: ${{ secrets.QUAY_USERNAME }}
166169
password: ${{ secrets.QUAY_ROBOT_TOKEN }}
167170

171+
- name: Login to GHCR
172+
if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/v') }}
173+
uses: docker/login-action@v3
174+
with:
175+
registry: ghcr.io
176+
username: ${{ github.repository_owner }}
177+
password: ${{ secrets.GITHUB_TOKEN }}
178+
168179
- name: Build and push
169180
id: build
170181
uses: docker/build-push-action@v6
@@ -176,8 +187,13 @@ jobs:
176187
push: true
177188
tags: ${{ steps.meta.outputs.tags }}
178189
labels: ${{ steps.meta.outputs.labels }}
190+
# FIXME: mount cache in the container
191+
# https://github.com/reproducible-containers/buildkit-cache-dance
192+
# https://docs.docker.com/build/ci/github-actions/cache/#cache-mounts
179193
cache-from: type=gha
180194
cache-to: type=gha,mode=max
195+
build-args: |
196+
GO_TAG=${{ steps.set-go.outputs.go-version }}
181197
182198
- name: Build to TAR
183199
id: build_tar
@@ -207,8 +223,7 @@ jobs:
207223
pushd config/installation
208224
kustomize edit set image rabbitmqoperator/cluster-operator-dev=rabbitmqoperator/cluster-operator:"${RELEASE_VERSION}"
209225
popd
210-
make generate-installation-manifest QUAY_IO_OPERATOR_IMAGE=quay.io/rabbitmqoperator/cluster-operator:"${RELEASE_VERSION}"
211-
echo -n "cluster-operator-${{ steps.meta.outputs.version }}.yml" > "latest-cluster-operator-dev-manifest.txt"
226+
make generate-installation-manifest QUAY_IO_OPERATOR_IMAGE=quay.io/rabbitmqoperator/cluster-operator:"${RELEASE_VERSION}" GHCR_IO_OPERATOR_IMAGE=ghcr.io/rabbitmq/cluster-operator:"${RELEASE_VERSION}"
212227
213228
- name: Upload operator manifests
214229
uses: actions/upload-artifact@v4
@@ -227,7 +242,7 @@ jobs:
227242
rabbitmq-image:
228243
- rabbitmq:3.13.7-management
229244
- rabbitmq:management
230-
- pivotalrabbitmq/rabbitmq:main
245+
- pivotalrabbitmq/rabbitmq:main-otp27
231246
steps:
232247
- name: Check out code into the Go module directory
233248
uses: actions/checkout@v5
@@ -491,6 +506,7 @@ jobs:
491506
files: |
492507
cluster-operator.yml
493508
cluster-operator-quay-io.yml
509+
cluster-operator-ghcr-io.yml
494510
generate_release_notes: true
495511
draft: true
496512
body_path: release-header.md

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
ARG GO_TAG=1.24
12
# Build the manager binary
2-
FROM --platform=$BUILDPLATFORM golang:1.24 AS builder
3+
FROM --platform=$BUILDPLATFORM golang:${GO_TAG} AS builder
34

45
WORKDIR /workspace
56

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,13 @@ $(YTT): | $(LOCAL_TESTBIN)
193193
chmod +x $(YTT)
194194

195195
QUAY_IO_OPERATOR_IMAGE ?= quay.io/rabbitmqoperator/cluster-operator:latest
196+
GHCR_IO_OPERATOR_IMAGE ?= ghcr.io/rabbitmq/cluster-operator:latest
196197
# Builds a single-file installation manifest to deploy the Operator
197198
generate-installation-manifest: | $(YTT)
198199
mkdir -p releases
199200
kustomize build config/installation/ > releases/cluster-operator.yml
200201
$(YTT) -f releases/cluster-operator.yml -f config/ytt/overlay-manager-image.yaml --data-value operator_image=$(QUAY_IO_OPERATOR_IMAGE) > releases/cluster-operator-quay-io.yml
202+
$(YTT) -f releases/cluster-operator.yml -f config/ytt/overlay-manager-image.yaml --data-value operator_image=$(GHCR_IO_OPERATOR_IMAGE) > releases/cluster-operator-ghcr-io.yml
201203

202204
docker-build: ## Build the docker image with tag `latest`
203205
@$(call check_defined, OPERATOR_IMAGE, path to the Operator image within the registry e.g. rabbitmq/cluster-operator)

0 commit comments

Comments
 (0)