Skip to content

Commit 076614c

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

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

.github/workflows/ci.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,9 +438,15 @@ jobs:
438438
registry: ghcr.io
439439
username: ${{ github.actor }}
440440
password: ${{ secrets.GITHUB_TOKEN }}
441+
- name: Set environment variables
442+
id: vars
443+
run: |
444+
echo "COMMIT_SHORT_SHA=${GITHUB_SHA:0:8}" >> $GITHUB_ENV
441445
- name: Build bundle-image
442446
env:
443447
BUNDLE_IMAGE: "ghcr.io/nvidia/gpu-operator/gpu-operator-bundle:${{ github.ref_name }}-latest"
448+
BUNDLE_IMAGE_TAG: "ghcr.io/nvidia/gpu-operator/gpu-operator-bundle:${{ env.COMMIT_SHORT_SHA }}"
449+
OPERATOR_IMAGE_TAG: "ghcr.io/nvidia/gpu-operator:${{ env.COMMIT_SHORT_SHA }}"
444450
VERSION: ""
445451
DEFAULT_CHANNEL: "stable"
446452
CHANNELS: "stable"

Makefile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
6060
# BUNDLE_IMAGE defines the image:tag used for the bundle.
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)
63+
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)
6366

6467
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
6568
ifeq (,$(shell go env GOBIN))
@@ -126,16 +129,23 @@ bundle: manifests install-tools
126129
$(KUSTOMIZE) build config/manifests | operator-sdk generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
127130
operator-sdk bundle validate ./bundle
128131

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+
@echo "Bundle CSV updated successfully"
137+
129138
# Build the bundle image.
130-
build-bundle-image:
139+
build-bundle-image: update-bundle-csv
131140
$(DOCKER) build \
132141
--build-arg DEFAULT_CHANNEL=$(DEFAULT_CHANNEL) \
133142
--build-arg GIT_COMMIT=$(GIT_COMMIT) \
134-
-f docker/bundle.Dockerfile -t $(BUNDLE_IMAGE) .
143+
-f docker/bundle.Dockerfile -t $(BUNDLE_IMAGE) -t $(BUNDLE_IMAGE_TAG) .
135144

136145
# Push the bundle image.
137146
push-bundle-image: build-bundle-image
138147
$(DOCKER) push $(BUNDLE_IMAGE)
148+
$(DOCKER) push $(BUNDLE_IMAGE_TAG)
139149

140150
# Define local and dockerized golang targets
141151

0 commit comments

Comments
 (0)