Skip to content

Commit

Permalink
Update github workflow for image builds to the latest standard one
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Klues <[email protected]>
  • Loading branch information
klueska committed Sep 13, 2024
1 parent 28a410e commit a54979f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 31 deletions.
37 changes: 18 additions & 19 deletions .github/workflows/images.yaml → .github/workflows/image.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 NVIDIA CORPORATION
# Copyright 2024 NVIDIA CORPORATION
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -12,9 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

name: Images
# Run this workflow on pull requests or merge to main/release branches
name: Image

# Run this workflow on pull requests
on:
pull_request:
types:
Expand All @@ -29,18 +29,14 @@ on:
- release-*

jobs:
build-image:
# We trigger image builds on push events (MERGED pull requests) or on non-closed PRs that are not created against a fork.
if: |
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) ||
(github.event_name == 'push')
build:
runs-on: ubuntu-latest
strategy:
matrix:
dist: [ubuntu20.04]
dist: [ubuntu20.04, ubi8]
steps:
- uses: actions/checkout@v4

name: Check out code
- name: Calculate build vars
id: vars
run: |
Expand All @@ -49,28 +45,31 @@ jobs:
REPO_FULL_NAME="${{ github.event.pull_request.head.repo.full_name }}"
echo "${REPO_FULL_NAME}"
echo "LABEL_IMAGE_SOURCE=https://github.com/${REPO_FULL_NAME}" >> $GITHUB_ENV
GENERATE_ARTIFACTS="false"
if [[ "${{ github.actor }}" == "dependabot[bot]" ]]; then
echo "PUSH_ON_BUILD=false" >> $GITHUB_ENV
else
echo "PUSH_ON_BUILD=true" >> $GITHUB_ENV
GENERATE_ARTIFACTS="false"
elif [[ "${{ github.event_name }}" == "pull_request" && "${{ github.event.pull_request.head.repo.full_name }}" == "${{ github.repository }}" ]]; then
GENERATE_ARTIFACTS="true"
elif [[ "${{ github.event_name }}" == "push" ]]; then
GENERATE_ARTIFACTS="true"
fi
echo "PUSH_ON_BUILD=${GENERATE_ARTIFACTS}" >> $GITHUB_ENV
echo "BUILD_MULTI_ARCH_IMAGES=${GENERATE_ARTIFACTS}" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build image
env:
IMAGE_NAME: ghcr.io/${LOWERCASE_REPO_OWNER}/k8s-dra-driver
IMAGE_NAME: ghcr.io/${LOWERCASE_REPO_OWNER}/k8s-device-plugin
VERSION: ${COMMIT_SHORT_SHA}
# TODO: For now we only build single-arch images to speed up development.
BUILD_MULTI_ARCH_IMAGES: "false"
run: |
echo "${VERSION}"
make -f deployments/container/Makefile build-${{ matrix.dist }}
12 changes: 5 additions & 7 deletions deployments/container/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ endif
MKDIR ?= mkdir

##### Global variables #####
include $(CURDIR)/common.mk
include $(CURDIR)/versions.mk

ifeq ($(IMAGE_NAME),)
REGISTRY ?= nvcr.io/nvidia/cloud-native
IMAGE_NAME = $(REGISTRY)/k8s-dra-driver
IMAGE_NAME := $(REGISTRY)/$(DRIVER_NAME)
endif

IMAGE_VERSION := $(VERSION)
Expand Down Expand Up @@ -102,10 +100,10 @@ $(DEFAULT_PUSH_TARGET): DIST = $(DEFAULT_PUSH_TARGET)
REGCTL ?= regctl
$(PUSH_TARGETS): push-%:
$(REGCTL) \
image copy \
$(IMAGE) $(OUT_IMAGE)
image copy \
$(IMAGE) $(OUT_IMAGE)

push-short:
$(REGCTL) \
image copy \
$(IMAGE) $(OUT_IMAGE_NAME):$(OUT_IMAGE_VERSION)
image copy \
$(IMAGE) $(OUT_IMAGE_NAME):$(OUT_IMAGE_VERSION)
3 changes: 1 addition & 2 deletions deployments/container/multi-arch.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
# limitations under the License.

PUSH_ON_BUILD ?= false
ATTACH_ATTESTATIONS ?= false
DOCKER_BUILD_OPTIONS = --output=type=image,push=$(PUSH_ON_BUILD) --provenance=$(ATTACH_ATTESTATIONS) --sbom=$(ATTACH_ATTESTATIONS)
DOCKER_BUILD_OPTIONS = --output=type=image,push=$(PUSH_ON_BUILD)
DOCKER_BUILD_PLATFORM_OPTIONS = --platform=linux/amd64,linux/arm64

$(BUILD_TARGETS): build-%: image-%
8 changes: 5 additions & 3 deletions versions.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) NVIDIA CORPORATION. All rights reserved.
# Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -18,18 +18,20 @@ MODULE := github.com/NVIDIA/$(DRIVER_NAME)
REGISTRY ?= nvcr.io/nvidia/cloud-native

VERSION ?= v0.1.0

# vVERSION represents the version with a guaranteed v-prefix
vVERSION := v$(VERSION:v%=%)

GOLANG_VERSION ?= 1.23.1
CUDA_VERSION ?= 11.8.0
CUDA_VERSION ?= 12.3.2

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

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

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

0 comments on commit a54979f

Please sign in to comment.