Skip to content

Commit 682d9fa

Browse files
authored
Merge pull request #785 from elezar/cherry-pick-sign
[no-relnote] add ngc image signing job for auto signing
2 parents 9ab4433 + 77db389 commit 682d9fa

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

.common-ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ stages:
2828
- test
2929
- scan
3030
- release
31+
- sign
3132

3233
.pipeline-trigger-rules:
3334
rules:

.nvidia-ci.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,63 @@ release:ngc-ubi8:
127127
extends:
128128
- .release:ngc
129129
- .dist-ubi8
130+
131+
# Define the external image signing steps for NGC
132+
# Download the ngc cli binary for use in the sign steps
133+
.ngccli-setup:
134+
before_script:
135+
- apt-get update && apt-get install -y curl unzip jq
136+
- |
137+
if [ -z "${NGCCLI_VERSION}" ]; then
138+
NGC_VERSION_URL="https://api.ngc.nvidia.com/v2/resources/nvidia/ngc-apps/ngc_cli/versions"
139+
# Extract the latest version from the JSON data using jq
140+
export NGCCLI_VERSION=$(curl -s $NGC_VERSION_URL | jq -r '.recipe.latestVersionIdStr')
141+
fi
142+
echo "NGCCLI_VERSION ${NGCCLI_VERSION}"
143+
- curl -sSLo ngccli_linux.zip https://api.ngc.nvidia.com/v2/resources/nvidia/ngc-apps/ngc_cli/versions/${NGCCLI_VERSION}/files/ngccli_linux.zip
144+
- unzip ngccli_linux.zip
145+
- chmod u+x ngc-cli/ngc
146+
147+
# .sign forms the base of the deployment jobs which signs images in the CI registry.
148+
# This is extended with the image name and version to be deployed.
149+
.sign:ngc:
150+
image: ubuntu:latest
151+
stage: sign
152+
rules:
153+
- if: $CI_COMMIT_TAG
154+
variables:
155+
NGC_CLI_API_KEY: "${NGC_REGISTRY_TOKEN}"
156+
IMAGE_NAME: "${NGC_REGISTRY_IMAGE}"
157+
IMAGE_TAG: "${CI_COMMIT_TAG}-${DIST}"
158+
retry:
159+
max: 2
160+
before_script:
161+
- !reference [.ngccli-setup, before_script]
162+
# We ensure that the IMAGE_NAME and IMAGE_TAG is set
163+
- 'echo Image Name: ${IMAGE_NAME} && [[ -n "${IMAGE_NAME}" ]] || exit 1'
164+
- 'echo Image Tag: ${IMAGE_TAG} && [[ -n "${IMAGE_TAG}" ]] || exit 1'
165+
script:
166+
- 'echo "Signing the image ${IMAGE_NAME}:${IMAGE_TAG}"'
167+
- ngc-cli/ngc registry image publish --source ${IMAGE_NAME}:${IMAGE_TAG} ${IMAGE_NAME}:${IMAGE_TAG} --public --discoverable --allow-guest --sign --org nvidia
168+
169+
sign:ngc-short-tag:
170+
extends:
171+
- .sign:ngc
172+
needs:
173+
- release:ngc-ubuntu22.04
174+
variables:
175+
IMAGE_TAG: "${CI_COMMIT_TAG}"
176+
177+
sign:ngc-ubuntu22.04:
178+
extends:
179+
- .dist-ubuntu22.04
180+
- .sign:ngc
181+
needs:
182+
- release:ngc-ubuntu22.04
183+
184+
sign:ngc-ubi8:
185+
extends:
186+
- .dist-ubi8
187+
- .sign:ngc
188+
needs:
189+
- release:ngc-ubi8

0 commit comments

Comments
 (0)