Skip to content

Commit 42588f1

Browse files
committed
add support for building artifacts with custom GOPROXY
Signed-off-by: Tariq Ibrahim <[email protected]>
1 parent af276bf commit 42588f1

File tree

6 files changed

+28
-9
lines changed

6 files changed

+28
-9
lines changed

.github/workflows/basic-checks.yaml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@ on:
99
golang_version:
1010
description: "The golang version for this project"
1111
value: ${{ jobs.variables.outputs.golang_version }}
12-
pull_request:
13-
types:
14-
- opened
15-
- synchronize
16-
branches:
17-
- main
18-
- release-*
1912

2013
jobs:
2114
variables:
@@ -25,6 +18,7 @@ jobs:
2518
needs:
2619
- variables
2720
uses: ./.github/workflows/golang.yaml
21+
secrets: inherit
2822
with:
2923
golang_version: ${{ needs.variables.outputs.golang_version }}
3024

.github/workflows/ci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ on:
2323

2424
jobs:
2525
basic:
26+
secrets: inherit
2627
uses: ./.github/workflows/basic-checks.yaml
2728

2829
image:

.github/workflows/golang.yaml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,22 @@ jobs:
5454
- run: make test
5555
build:
5656
name: Build
57-
runs-on: ubuntu-latest
57+
runs-on: linux-amd64-cpu4
58+
permissions:
59+
contents: read
60+
id-token: write
5861
steps:
5962
- name: Checkout code
6063
uses: actions/checkout@v5
6164
- name: Install Go
6265
uses: actions/setup-go@v6
6366
with:
6467
go-version: ${{ inputs.golang_version }}
65-
- run: make build
68+
69+
- name: Setup Go Proxy
70+
id: setup-go-proxy
71+
uses: nv-gha-runners/setup-artifactory-go-proxy@main
72+
- env:
73+
GOPROXY: ${{ steps.setup-go-proxy.outputs.goproxy }}
74+
run: |
75+
make build

.github/workflows/image.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ on:
2727
jobs:
2828
build:
2929
runs-on: linux-amd64-cpu4
30+
permissions:
31+
contents: read
32+
id-token: write
33+
packages: write
3034
steps:
3135
- uses: actions/checkout@v5
3236
name: Check out code
@@ -42,12 +46,16 @@ jobs:
4246
registry: ghcr.io
4347
username: ${{ github.actor }}
4448
password: ${{ secrets.GITHUB_TOKEN }}
49+
- name: Setup Go Proxy
50+
id: setup-go-proxy
51+
uses: nv-gha-runners/setup-artifactory-go-proxy@main
4552
- name: Build image
4653
env:
4754
IMAGE_NAME: ghcr.io/nvidia/k8s-device-plugin
4855
VERSION: ${{ inputs.version }}
4956
PUSH_ON_BUILD: true
5057
BUILD_MULTI_ARCH_IMAGES: ${{ inputs.build_multi_arch_images }}
58+
GOPROXY: ${{ steps.setup-go-proxy.outputs.goproxy }}
5159
run: |
5260
echo "${VERSION}"
5361
make -f deployments/container/Makefile build

deployments/container/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ FROM base AS devel
2020
WORKDIR /work
2121
COPY * .
2222

23+
ARG GOPROXY="https://proxy.golang.org,direct"
24+
ENV GOPROXY=$GOPROXY
25+
2326
RUN make install-tools
2427

2528
# We need to set the /work directory as a safe directory.

deployments/container/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ MKDIR ?= mkdir
2323
##### Global variables #####
2424
include $(CURDIR)/versions.mk
2525

26+
GOPROXY ?= https://proxy.golang.org,direct
27+
2628
ifeq ($(IMAGE_NAME),)
2729
IMAGE_NAME := $(REGISTRY)/$(DRIVER_NAME)
2830
endif
@@ -78,6 +80,7 @@ $(IMAGE_TARGETS): image-%:
7880
--tag $(IMAGE) \
7981
--build-arg VERSION="$(VERSION)" \
8082
--build-arg GIT_COMMIT="$(GIT_COMMIT)" \
83+
--build-arg GOPROXY="$(GOPROXY)" \
8184
$(if $(LABEL_IMAGE_SOURCE),--label "org.opencontainers.image.source=$(LABEL_IMAGE_SOURCE)",) \
8285
-f $(DOCKERFILE) \
8386
$(CURDIR)

0 commit comments

Comments
 (0)