Skip to content

Commit

Permalink
add ngc signing job for auto signing
Browse files Browse the repository at this point in the history
Signed-off-by: shiva kumar <shivaku@nvidia.com>
  • Loading branch information
shivakunv committed Jun 11, 2024
1 parent da661c0 commit 4aee6c2
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
1 change: 1 addition & 0 deletions .common-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ stages:
- test
- scan
- release
- sign

# Define the distribution targets
.dist-ubi8:
Expand Down
57 changes: 57 additions & 0 deletions .nvidia-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,60 @@ release:ngc-ubi8:
extends:
- .release:ngc
- .dist-ubi8

# Define the external image signing steps for NGC
# Download the ngc cli binary for use in the sign steps
.ngccli-setup:
before_script:
- apt-get update && apt-get install -y curl unzip jq
- |
export NGCLI_VERSION="3.41.4"
NGC_VERSION_URL="https://api.ngc.nvidia.com/v2/resources/nvidia/ngc-apps/ngc_cli/versions"
json_data=$(curl -s $NGC_VERSION_URL)
# Extract the latest version from the JSON data using jq
latest_version=$(echo $json_data | jq -r '.recipe.latestVersionIdStr')
echo "${latest_version}"
if [ -n "$latest_version" ]; then
export NGCLI_VERSION=$latest_version
fi
echo "NGCLI_VERSION ${NGCLI_VERSION}"
- curl -sSLo ngccli_linux.zip https://api.ngc.nvidia.com/v2/resources/nvidia/ngc-apps/ngc_cli/versions/${NGCLI_VERSION}/files/ngccli_linux.zip
- unzip ngccli_linux.zip
- chmod u+x ngc-cli/ngc

# .sign forms the base of the deployment jobs which signs images in the CI registry.
# This is extended with the image name and version to be deployed.
.sign:ngc:
image: ubuntu:latest
when: always
stage: sign
rules:
- if: $CI_COMMIT_TAG
variables:
NGC_CLI_API_KEY: "${NGC_REGISTRY_TOKEN}"
IMAGE_NAME: "${NGC_REGISTRY_IMAGE}"
IMAGE_TAG: "${CI_COMMIT_TAG}-${DIST}"
retry:
max: 2
before_script:
- !reference [.ngccli-setup, before_script]
# We ensure that the IMAGE_NAME and IMAGE_TAG is set
- 'echo Image Name: ${IMAGE_NAME} && [[ -n "${IMAGE_NAME}" ]] || exit 1 && echo Image Tag: ${IMAGE_TAG} && [[ -n "${IMAGE_TAG}" ]] || exit 1'
script:
- 'echo "Signing the image ${IMAGE_NAME}:${IMAGE_TAG}"'
- ngc-cli/ngc registry image publish --source ${IMAGE_NAME}:${IMAGE_TAG} ${IMAGE_NAME}:${IMAGE_TAG} --public --discoverable --allow-guest --sign --org nvidia

sign:ngc-short-tag:
extends:
- .sign:ngc
variables:
IMAGE_TAG: "${CI_COMMIT_TAG}"
needs:
- release:ngc-ubi8

sign:ngc-ubi8:
extends:
- .dist-ubi8
- .sign:ngc
needs:
- release:ngc-ubi8

0 comments on commit 4aee6c2

Please sign in to comment.