Skip to content

Commit 271f5a7

Browse files
committed
feat: Add GHCR support for image publishing and manifests
This commit introduces support for GitHub Container Registry (GHCR) in the messaging-topology-operator's CI/CD pipeline. Previously, images were only pushed to Docker Hub and Quay.io. Key changes include: * Updating the GitHub Actions workflow to log in to GHCR and push built images. * Modifying the Makefile to define the GHCR image and generate Kubernetes manifests that reference the GHCR hosted images. This enhancement allows for broader distribution and accessibility of the operator images.
1 parent 24c1c7c commit 271f5a7

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

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

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,19 @@ jobs:
6363
permissions:
6464
contents: 'write'
6565
id-token: 'write'
66+
packages: 'write'
6667
outputs:
6768
image_tag: ${{ steps.meta.outputs.version }}
6869
steps:
6970
- name: Checkout code
7071
uses: actions/checkout@v5
7172

7273
- name: Install Go
74+
id: set-go
7375
uses: actions/setup-go@v6
7476
with:
7577
go-version-file: go.mod
78+
check-latest: true
7679

7780
- name: OCI Metadata
7881
id: meta
@@ -81,6 +84,7 @@ jobs:
8184
images: |
8285
rabbitmqoperator/messaging-topology-operator
8386
quay.io/rabbitmqoperator/messaging-topology-operator
87+
ghcr.io/rabbitmq/messaging-topology-operator
8488
# generate Docker tags based on the following events/attributes
8589
tags: |
8690
type=sha
@@ -93,22 +97,30 @@ jobs:
9397
uses: docker/setup-buildx-action@v3
9498

9599
- name: Login to Docker Hub
96-
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
100+
if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/v') }}
97101
uses: docker/login-action@v3
98102
with:
99103
username: ${{ secrets.DOCKERHUB_USERNAME }}
100104
password: ${{ secrets.DOCKERHUB_TOKEN }}
101105

102106
- name: Login to Quay.io
103-
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
107+
if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/v') }}
104108
uses: docker/login-action@v3
105109
with:
106110
registry: quay.io
107111
username: ${{ secrets.QUAY_USERNAME }}
108112
password: ${{ secrets.QUAY_ROBOT_TOKEN }}
109113

114+
- name: Login to GHCR
115+
if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/v') }}
116+
uses: docker/login-action@v3
117+
with:
118+
registry: ghcr.io
119+
username: ${{ github.repository_owner }}
120+
password: ${{ secrets.GITHUB_TOKEN }}
121+
110122
- name: Build and push
111-
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
123+
if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/v') }}
112124
uses: docker/build-push-action@v6
113125
with:
114126
context: .
@@ -117,6 +129,8 @@ jobs:
117129
provenance: false
118130
tags: ${{ steps.meta.outputs.tags }}
119131
labels: ${{ steps.meta.outputs.labels }}
132+
build-args: |
133+
GO_TAG=${{ steps.set-go.outputs.go-version }}
120134
121135
- name: Build to TAR
122136
id: build_tar
@@ -128,6 +142,8 @@ jobs:
128142
labels: ${{ steps.meta.outputs.labels }}
129143
outputs: |
130144
type=docker,dest=./operator.tar
145+
build-args: |
146+
GO_TAG=${{ steps.set-go.outputs.go-version }}
131147
132148
- name: Upload Operator artifact
133149
uses: actions/upload-artifact@v4
@@ -149,7 +165,7 @@ jobs:
149165
kustomize edit set image \
150166
rabbitmqoperator/messaging-topology-operator-dev=rabbitmqoperator/messaging-topology-operator:"${RELEASE_VERSION}"
151167
popd
152-
make generate-manifests QUAY_IO_OPERATOR_IMAGE=quay.io/rabbitmqoperator/messaging-topology-operator:"${RELEASE_VERSION}"
168+
make generate-manifests QUAY_IO_OPERATOR_IMAGE=quay.io/rabbitmqoperator/messaging-topology-operator:"${RELEASE_VERSION}" GHCR_IO_OPERATOR_IMAGE=ghcr.io/rabbitmq/messaging-topology-operator:"${RELEASE_VERSION}"
153169
154170
- name: Upload operator manifests
155171
uses: actions/upload-artifact@v4
@@ -174,6 +190,10 @@ jobs:
174190
contents: 'write'
175191
id-token: 'write'
176192
needs: build_operator
193+
env:
194+
# Taken from https://github.com/kubernetes-sigs/kind/releases/tag/v0.18.0
195+
# The image here should be listed under 'Images built for this release' for the version of kind in go.mod
196+
KIND_NODE_IMAGE: "kindest/node:v1.32.0"
177197
steps:
178198
- name: Check out code
179199
uses: actions/checkout@v5

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
# Copy the Go Modules manifests

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,18 @@ api-reference: install-tools
159159
--max-depth 30
160160

161161
QUAY_IO_OPERATOR_IMAGE ?= quay.io/rabbitmqoperator/messaging-topology-operator:latest
162+
GHCR_IO_OPERATOR_IMAGE ?= ghcr.io/rabbitmq/messaging-topology-operator:latest
162163
## used in CI pipeline to create release artifact
163164
.PHONY: generate-manifests
164165
generate-manifests: | $(YTT)
165166
mkdir -p releases
166167
kustomize build config/installation/ > releases/messaging-topology-operator.bak
167168
sed '/CERTIFICATE_NAMESPACE.*CERTIFICATE_NAME/d' releases/messaging-topology-operator.bak > releases/messaging-topology-operator.yaml
168169
$(YTT) -f releases/messaging-topology-operator.yaml -f config/ytt_overlays/change_deployment_image.yml --data-value operator_image=$(QUAY_IO_OPERATOR_IMAGE) > releases/messaging-topology-operator-quay-io.yaml
170+
$(YTT) -f releases/messaging-topology-operator.yaml -f config/ytt_overlays/change_deployment_image.yml --data-value operator_image=$(GHCR_IO_OPERATOR_IMAGE) > releases/messaging-topology-operator-ghcr-io.yaml
169171
kustomize build config/installation/cert-manager/ > releases/messaging-topology-operator-with-certmanager.yaml
170172
$(YTT) -f releases/messaging-topology-operator-with-certmanager.yaml -f config/ytt_overlays/change_deployment_image.yml --data-value operator_image=$(QUAY_IO_OPERATOR_IMAGE) > releases/messaging-topology-operator-with-certmanager-quay-io.yaml
173+
$(YTT) -f releases/messaging-topology-operator-with-certmanager.yaml -f config/ytt_overlays/change_deployment_image.yml --data-value operator_image=$(GHCR_IO_OPERATOR_IMAGE) > releases/messaging-topology-operator-with-certmanager-ghcr-io.yaml
171174

172175
# Run go fmt against code
173176
fmt:

0 commit comments

Comments
 (0)