Skip to content

Commit 98b0831

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

File tree

6 files changed

+46
-9
lines changed

6 files changed

+46
-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: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,31 @@ 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 JFrog CLI
70+
id: jfrog
71+
uses: jfrog/setup-jfrog-cli@v4
72+
env:
73+
JF_URL: https://${{ secrets.OIDC_ARTIFACTORY_ENDPOINT }}/
74+
with:
75+
oidc-provider-name: nvgithub
76+
oidc-audience: ${{ secrets.OIDC_ARTIFACTORY_ENDPOINT }}
77+
- env:
78+
OIDC_USER: ${{ steps.jfrog.outputs.oidc-user }}
79+
OIDC_TOKEN: ${{ steps.jfrog.outputs.oidc-token }}
80+
OIDC_ARTIFACTORY_ENDPOINT: ${{ secrets.OIDC_ARTIFACTORY_ENDPOINT }}
81+
run: |
82+
OIDC_USER_ENCODED=$(python3 -c 'import urllib.parse, os; print(urllib.parse.quote_plus(os.environ["OIDC_USER"]))')
83+
export GOPROXY="https://${OIDC_USER_ENCODED}:${OIDC_TOKEN}@${OIDC_ARTIFACTORY_ENDPOINT}/artifactory/api/go/edge-go-remote-virtual"
84+
make build

.github/workflows/image.yaml

Lines changed: 17 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,25 @@ jobs:
4246
registry: ghcr.io
4347
username: ${{ github.actor }}
4448
password: ${{ secrets.GITHUB_TOKEN }}
49+
- name: Setup JFrog CLI
50+
id: jfrog
51+
uses: jfrog/setup-jfrog-cli@v4
52+
env:
53+
JF_URL: https://${{ secrets.OIDC_ARTIFACTORY_ENDPOINT }}/
54+
with:
55+
oidc-provider-name: nvgithub
56+
oidc-audience: ${{ secrets.OIDC_ARTIFACTORY_ENDPOINT }}
4557
- name: Build image
4658
env:
4759
IMAGE_NAME: ghcr.io/nvidia/k8s-device-plugin
4860
VERSION: ${{ inputs.version }}
4961
PUSH_ON_BUILD: true
5062
BUILD_MULTI_ARCH_IMAGES: ${{ inputs.build_multi_arch_images }}
63+
OIDC_USER: ${{ steps.jfrog.outputs.oidc-user }}
64+
OIDC_TOKEN: ${{ steps.jfrog.outputs.oidc-token }}
65+
OIDC_ARTIFACTORY_ENDPOINT: ${{ secrets.OIDC_ARTIFACTORY_ENDPOINT }}
5166
run: |
67+
OIDC_USER_ENCODED=$(python3 -c 'import urllib.parse, os; print(urllib.parse.quote_plus(os.environ["OIDC_USER"]))')
68+
export GOPROXY="https://${OIDC_USER_ENCODED}:${OIDC_TOKEN}@${OIDC_ARTIFACTORY_ENDPOINT}/artifactory/api/go/edge-go-remote-virtual"
5269
echo "${VERSION}"
5370
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=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 ?= 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)