Skip to content

Commit f880bcc

Browse files
authored
Merge pull request #160 from klueska/update-image-build-github-action
Update github workflow for image builds to the latest standard one
2 parents 28a410e + a54979f commit f880bcc

File tree

4 files changed

+29
-31
lines changed

4 files changed

+29
-31
lines changed
Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2023 NVIDIA CORPORATION
1+
# Copyright 2024 NVIDIA CORPORATION
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -12,9 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
name: Images
15+
# Run this workflow on pull requests or merge to main/release branches
16+
name: Image
1617

17-
# Run this workflow on pull requests
1818
on:
1919
pull_request:
2020
types:
@@ -29,18 +29,14 @@ on:
2929
- release-*
3030

3131
jobs:
32-
build-image:
33-
# We trigger image builds on push events (MERGED pull requests) or on non-closed PRs that are not created against a fork.
34-
if: |
35-
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) ||
36-
(github.event_name == 'push')
32+
build:
3733
runs-on: ubuntu-latest
3834
strategy:
3935
matrix:
40-
dist: [ubuntu20.04]
36+
dist: [ubuntu20.04, ubi8]
4137
steps:
4238
- uses: actions/checkout@v4
43-
39+
name: Check out code
4440
- name: Calculate build vars
4541
id: vars
4642
run: |
@@ -49,28 +45,31 @@ jobs:
4945
REPO_FULL_NAME="${{ github.event.pull_request.head.repo.full_name }}"
5046
echo "${REPO_FULL_NAME}"
5147
echo "LABEL_IMAGE_SOURCE=https://github.com/${REPO_FULL_NAME}" >> $GITHUB_ENV
48+
49+
GENERATE_ARTIFACTS="false"
5250
if [[ "${{ github.actor }}" == "dependabot[bot]" ]]; then
53-
echo "PUSH_ON_BUILD=false" >> $GITHUB_ENV
54-
else
55-
echo "PUSH_ON_BUILD=true" >> $GITHUB_ENV
51+
GENERATE_ARTIFACTS="false"
52+
elif [[ "${{ github.event_name }}" == "pull_request" && "${{ github.event.pull_request.head.repo.full_name }}" == "${{ github.repository }}" ]]; then
53+
GENERATE_ARTIFACTS="true"
54+
elif [[ "${{ github.event_name }}" == "push" ]]; then
55+
GENERATE_ARTIFACTS="true"
5656
fi
57-
57+
echo "PUSH_ON_BUILD=${GENERATE_ARTIFACTS}" >> $GITHUB_ENV
58+
echo "BUILD_MULTI_ARCH_IMAGES=${GENERATE_ARTIFACTS}" >> $GITHUB_ENV
59+
- name: Set up QEMU
60+
uses: docker/setup-qemu-action@v3
5861
- name: Set up Docker Buildx
5962
uses: docker/setup-buildx-action@v3
60-
6163
- name: Login to GitHub Container Registry
6264
uses: docker/login-action@v3
6365
with:
6466
registry: ghcr.io
6567
username: ${{ github.actor }}
6668
password: ${{ secrets.GITHUB_TOKEN }}
67-
6869
- name: Build image
6970
env:
70-
IMAGE_NAME: ghcr.io/${LOWERCASE_REPO_OWNER}/k8s-dra-driver
71+
IMAGE_NAME: ghcr.io/${LOWERCASE_REPO_OWNER}/k8s-device-plugin
7172
VERSION: ${COMMIT_SHORT_SHA}
72-
# TODO: For now we only build single-arch images to speed up development.
73-
BUILD_MULTI_ARCH_IMAGES: "false"
7473
run: |
7574
echo "${VERSION}"
7675
make -f deployments/container/Makefile build-${{ matrix.dist }}

deployments/container/Makefile

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@ endif
2121
MKDIR ?= mkdir
2222

2323
##### Global variables #####
24-
include $(CURDIR)/common.mk
2524
include $(CURDIR)/versions.mk
2625

2726
ifeq ($(IMAGE_NAME),)
28-
REGISTRY ?= nvcr.io/nvidia/cloud-native
29-
IMAGE_NAME = $(REGISTRY)/k8s-dra-driver
27+
IMAGE_NAME := $(REGISTRY)/$(DRIVER_NAME)
3028
endif
3129

3230
IMAGE_VERSION := $(VERSION)
@@ -102,10 +100,10 @@ $(DEFAULT_PUSH_TARGET): DIST = $(DEFAULT_PUSH_TARGET)
102100
REGCTL ?= regctl
103101
$(PUSH_TARGETS): push-%:
104102
$(REGCTL) \
105-
image copy \
106-
$(IMAGE) $(OUT_IMAGE)
103+
image copy \
104+
$(IMAGE) $(OUT_IMAGE)
107105

108106
push-short:
109107
$(REGCTL) \
110-
image copy \
111-
$(IMAGE) $(OUT_IMAGE_NAME):$(OUT_IMAGE_VERSION)
108+
image copy \
109+
$(IMAGE) $(OUT_IMAGE_NAME):$(OUT_IMAGE_VERSION)

deployments/container/multi-arch.mk

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
# limitations under the License.
1414

1515
PUSH_ON_BUILD ?= false
16-
ATTACH_ATTESTATIONS ?= false
17-
DOCKER_BUILD_OPTIONS = --output=type=image,push=$(PUSH_ON_BUILD) --provenance=$(ATTACH_ATTESTATIONS) --sbom=$(ATTACH_ATTESTATIONS)
16+
DOCKER_BUILD_OPTIONS = --output=type=image,push=$(PUSH_ON_BUILD)
1817
DOCKER_BUILD_PLATFORM_OPTIONS = --platform=linux/amd64,linux/arm64
1918

2019
$(BUILD_TARGETS): build-%: image-%

versions.mk

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) NVIDIA CORPORATION. All rights reserved.
1+
# Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -18,18 +18,20 @@ MODULE := github.com/NVIDIA/$(DRIVER_NAME)
1818
REGISTRY ?= nvcr.io/nvidia/cloud-native
1919

2020
VERSION ?= v0.1.0
21+
2122
# vVERSION represents the version with a guaranteed v-prefix
2223
vVERSION := v$(VERSION:v%=%)
2324

2425
GOLANG_VERSION ?= 1.23.1
25-
CUDA_VERSION ?= 11.8.0
26+
CUDA_VERSION ?= 12.3.2
2627

2728
# These variables are only needed when building a local image
2829
CLIENT_GEN_VERSION ?= v0.29.2
2930
CONTROLLER_GEN_VERSION ?= v0.14.0
3031
GOLANGCI_LINT_VERSION ?= v1.52.0
3132
MOQ_VERSION ?= v0.4.0
3233

33-
BUILDIMAGE ?= ghcr.io/nvidia/k8s-test-infra:devel-go$(GOLANG_VERSION)
34+
BUILDIMAGE_TAG ?= devel-go$(GOLANG_VERSION)
35+
BUILDIMAGE ?= ghcr.io/nvidia/k8s-test-infra:$(BUILDIMAGE_TAG)
3436

3537
GIT_COMMIT ?= $(shell git describe --match="" --dirty --long --always --abbrev=40 2> /dev/null || echo "")

0 commit comments

Comments
 (0)