From 42588f1ff9f55fac980c9f95dcc38ebd3b6d5168 Mon Sep 17 00:00:00 2001 From: Tariq Ibrahim Date: Fri, 26 Sep 2025 09:18:44 -0700 Subject: [PATCH] add support for building artifacts with custom GOPROXY Signed-off-by: Tariq Ibrahim --- .github/workflows/basic-checks.yaml | 8 +------- .github/workflows/ci.yaml | 1 + .github/workflows/golang.yaml | 14 ++++++++++++-- .github/workflows/image.yaml | 8 ++++++++ deployments/container/Dockerfile | 3 +++ deployments/container/Makefile | 3 +++ 6 files changed, 28 insertions(+), 9 deletions(-) diff --git a/.github/workflows/basic-checks.yaml b/.github/workflows/basic-checks.yaml index ed9d184cc..65f330b9c 100644 --- a/.github/workflows/basic-checks.yaml +++ b/.github/workflows/basic-checks.yaml @@ -9,13 +9,6 @@ on: golang_version: description: "The golang version for this project" value: ${{ jobs.variables.outputs.golang_version }} - pull_request: - types: - - opened - - synchronize - branches: - - main - - release-* jobs: variables: @@ -25,6 +18,7 @@ jobs: needs: - variables uses: ./.github/workflows/golang.yaml + secrets: inherit with: golang_version: ${{ needs.variables.outputs.golang_version }} diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b79e57413..9a7f9950b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -23,6 +23,7 @@ on: jobs: basic: + secrets: inherit uses: ./.github/workflows/basic-checks.yaml image: diff --git a/.github/workflows/golang.yaml b/.github/workflows/golang.yaml index cb54ede5e..8b18a2978 100644 --- a/.github/workflows/golang.yaml +++ b/.github/workflows/golang.yaml @@ -54,7 +54,10 @@ jobs: - run: make test build: name: Build - runs-on: ubuntu-latest + runs-on: linux-amd64-cpu4 + permissions: + contents: read + id-token: write steps: - name: Checkout code uses: actions/checkout@v5 @@ -62,4 +65,11 @@ jobs: uses: actions/setup-go@v6 with: go-version: ${{ inputs.golang_version }} - - run: make build + + - name: Setup Go Proxy + id: setup-go-proxy + uses: nv-gha-runners/setup-artifactory-go-proxy@main + - env: + GOPROXY: ${{ steps.setup-go-proxy.outputs.goproxy }} + run: | + make build diff --git a/.github/workflows/image.yaml b/.github/workflows/image.yaml index d7d6a2712..102414f73 100644 --- a/.github/workflows/image.yaml +++ b/.github/workflows/image.yaml @@ -27,6 +27,10 @@ on: jobs: build: runs-on: linux-amd64-cpu4 + permissions: + contents: read + id-token: write + packages: write steps: - uses: actions/checkout@v5 name: Check out code @@ -42,12 +46,16 @@ jobs: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Setup Go Proxy + id: setup-go-proxy + uses: nv-gha-runners/setup-artifactory-go-proxy@main - name: Build image env: IMAGE_NAME: ghcr.io/nvidia/k8s-device-plugin VERSION: ${{ inputs.version }} PUSH_ON_BUILD: true BUILD_MULTI_ARCH_IMAGES: ${{ inputs.build_multi_arch_images }} + GOPROXY: ${{ steps.setup-go-proxy.outputs.goproxy }} run: | echo "${VERSION}" make -f deployments/container/Makefile build diff --git a/deployments/container/Dockerfile b/deployments/container/Dockerfile index 40e193fa0..6c9584a03 100644 --- a/deployments/container/Dockerfile +++ b/deployments/container/Dockerfile @@ -20,6 +20,9 @@ FROM base AS devel WORKDIR /work COPY * . +ARG GOPROXY="https://proxy.golang.org,direct" +ENV GOPROXY=$GOPROXY + RUN make install-tools # We need to set the /work directory as a safe directory. diff --git a/deployments/container/Makefile b/deployments/container/Makefile index c20a6d7f6..7f042e8ef 100644 --- a/deployments/container/Makefile +++ b/deployments/container/Makefile @@ -23,6 +23,8 @@ MKDIR ?= mkdir ##### Global variables ##### include $(CURDIR)/versions.mk +GOPROXY ?= https://proxy.golang.org,direct + ifeq ($(IMAGE_NAME),) IMAGE_NAME := $(REGISTRY)/$(DRIVER_NAME) endif @@ -78,6 +80,7 @@ $(IMAGE_TARGETS): image-%: --tag $(IMAGE) \ --build-arg VERSION="$(VERSION)" \ --build-arg GIT_COMMIT="$(GIT_COMMIT)" \ + --build-arg GOPROXY="$(GOPROXY)" \ $(if $(LABEL_IMAGE_SOURCE),--label "org.opencontainers.image.source=$(LABEL_IMAGE_SOURCE)",) \ -f $(DOCKERFILE) \ $(CURDIR)