Skip to content

Commit c00e2f4

Browse files
Shiva Kumarshivakunv
authored andcommitted
Tag git commit sha with bundle image
Signed-off-by: Shiva Kumar (SW-CLOUD) <[email protected]>
1 parent 81a5911 commit c00e2f4

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

.github/workflows/ci.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,9 @@ jobs:
443443
echo "COMMIT_SHORT_SHA=${GITHUB_SHA:0:8}" >> $GITHUB_ENV
444444
- name: Build bundle-image
445445
env:
446-
BUNDLE_IMAGE: "ghcr.io/nvidia/gpu-operator/gpu-operator-bundle:${{ github.ref_name }}-latest"
447-
BUNDLE_IMAGE_TAG: "ghcr.io/nvidia/gpu-operator/gpu-operator-bundle:${{ env.COMMIT_SHORT_SHA }}"
446+
BUNDLE_IMAGE: "ghcr.io/nvidia/gpu-operator-bundle:${{ github.ref_name }}-latest"
447+
BUNDLE_IMAGE_TAG: "ghcr.io/nvidia/gpu-operator-bundle:${{ env.COMMIT_SHORT_SHA }}"
448+
OPERATOR_IMAGE_TAG: "ghcr.io/nvidia/gpu-operator:${{ env.COMMIT_SHORT_SHA }}"
448449
VERSION: ""
449450
DEFAULT_CHANNEL: "stable"
450451
CHANNELS: "stable"

Makefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
6161
# You can use it as an arg. (E.g make bundle-build BUNDLE_IMAGE=<some-registry>/<project-name-bundle>:<tag>)
6262
BUNDLE_IMAGE ?= gpu-operator-bundle:$(VERSION)
6363
BUNDLE_IMAGE_TAG ?= gpu-operator-bundle:$(VERSION)
64+
BUNDLE_CSV_FILE ?= bundle/manifests/gpu-operator-certified.clusterserviceversion.yaml
65+
OPERATOR_IMAGE_TAG ?= gpu-operator:$(VERSION)
6466

6567
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
6668
ifeq (,$(shell go env GOBIN))
@@ -127,6 +129,14 @@ bundle: manifests install-tools
127129
$(KUSTOMIZE) build config/manifests | operator-sdk generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
128130
operator-sdk bundle validate ./bundle
129131

132+
# update the bundle image tag in csv file
133+
update-bundle-csv:
134+
@echo "Updating GPU operator image in $(BUNDLE_CSV_FILE) to $(OPERATOR_IMAGE_TAG)"
135+
@sed -i -e 's|gpu-operator:[^ " ]*|$(OPERATOR_IMAGE_TAG)|g' $(BUNDLE_CSV_FILE)
136+
@git diff --exit-code -- $(BUNDLE_CSV_FILE)
137+
@cat $(BUNDLE_CSV_FILE)
138+
@echo "Bundle CSV updated successfully"
139+
130140
# Build the bundle image.
131141
build-bundle-image:
132142
$(DOCKER) build \
@@ -135,7 +145,7 @@ build-bundle-image:
135145
-f docker/bundle.Dockerfile -t $(BUNDLE_IMAGE) -t $(BUNDLE_IMAGE_TAG) .
136146

137147
# Push the bundle image.
138-
push-bundle-image: build-bundle-image
148+
push-bundle-image: update-bundle-csv build-bundle-image
139149
$(DOCKER) push $(BUNDLE_IMAGE)
140150
$(DOCKER) push $(BUNDLE_IMAGE_TAG)
141151

0 commit comments

Comments
 (0)