Skip to content

Commit cb0d983

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

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

.github/workflows/ci.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,9 +438,21 @@ 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
445+
- name: Update bundle CSV
446+
run: |
447+
sed -i'' -e 's|ghcr.io/nvidia/gpu-operator:[^ "]*|ghcr.io/nvidia/gpu-operator:${{ env.COMMIT_SHORT_SHA }}|g' bundle/manifests/gpu-operator-certified.clusterserviceversion.yaml
448+
echo "Bundle CSV updated successfully"
441449
- name: Build bundle-image
442450
env:
443-
BUNDLE_IMAGE: "ghcr.io/nvidia/gpu-operator/gpu-operator-bundle:${{ github.ref_name }}-latest"
451+
BUNDLE_IMAGE_NAME: "ghcr.io/nvidia/gpu-operator/gpu-operator-bundle"
452+
BUNDLE_VERSION: "bundlecommitsha-latest"
453+
BUNDLE_GIT_TAG: "${{ env.COMMIT_SHORT_SHA }}"
454+
OPERATOR_IMAGE_NAME: "ghcr.io/nvidia/gpu-operator"
455+
OPERATOR_VERSION: "${{ env.COMMIT_SHORT_SHA }}"
444456
VERSION: ""
445457
DEFAULT_CHANNEL: "stable"
446458
CHANNELS: "stable"

Makefile

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,14 @@ BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
5959

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>)
62-
BUNDLE_IMAGE ?= gpu-operator-bundle:$(VERSION)
62+
BUNDLE_IMAGE_NAME ?= gpu-operator-bundle
63+
BUNDLE_VERSION ?= $(VERSION)
64+
BUNDLE_GIT_TAG ?= $(GIT_COMMIT)
65+
OPERATOR_IMAGE_NAME ?= gpu-operator
66+
OPERATOR_VERSION ?= $(VERSION)
67+
68+
BUNDLE_IMAGE := $(BUNDLE_IMAGE_NAME):$(BUNDLE_VERSION)
69+
BUNDLE_IMAGE_GIT := $(if $(BUNDLE_GIT_TAG),$(BUNDLE_IMAGE_NAME):$(BUNDLE_GIT_TAG))
6370

6471
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
6572
ifeq (,$(shell go env GOBIN))
@@ -131,11 +138,15 @@ build-bundle-image:
131138
$(DOCKER) build \
132139
--build-arg DEFAULT_CHANNEL=$(DEFAULT_CHANNEL) \
133140
--build-arg GIT_COMMIT=$(GIT_COMMIT) \
134-
-f docker/bundle.Dockerfile -t $(BUNDLE_IMAGE) .
141+
-f docker/bundle.Dockerfile \
142+
-t $(BUNDLE_IMAGE) \
143+
$(if $(BUNDLE_IMAGE_GIT),-t $(BUNDLE_IMAGE_GIT)) \
144+
.
135145

136146
# Push the bundle image.
137147
push-bundle-image: build-bundle-image
138148
$(DOCKER) push $(BUNDLE_IMAGE)
149+
$(if $(BUNDLE_IMAGE_GIT),$(DOCKER) push $(BUNDLE_IMAGE_GIT))
139150

140151
# Define local and dockerized golang targets
141152

0 commit comments

Comments
 (0)