Skip to content

Commit 2ce7bf7

Browse files
authored
feat(gitlab/ci): add ngc publishing job (#38)
1 parent e19f178 commit 2ce7bf7

File tree

1 file changed

+124
-2
lines changed

1 file changed

+124
-2
lines changed

.gitlab-ci.yml

Lines changed: 124 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,29 @@ workflow:
3535
rules:
3636
- if: $CI_COMMIT_TAG
3737

38+
include:
39+
- project: dgx/infra/gitlint-ci
40+
ref: main
41+
file: gitlint.yml
42+
- project: dgx/infra/ngc-publishing-automation
43+
ref: main
44+
file: ngc-publishing-automation.yml
45+
rules:
46+
- if: $CI_COMMIT_TAG
47+
inputs:
48+
git_user: ${GITLAB_USER}
49+
git_email: ${GITLAB_USER}@exchange.nvidia.com
50+
team: skyhook
51+
artifact_map: artifacts.json
52+
email: ${NOTIFY_EMAIL}
53+
action: FULL
54+
nspect_id: ${NSPECT_ID}
55+
public: True
56+
needs:
57+
- job: bootstrap
58+
artifacts: true
59+
- job: assemble-artifacts
60+
artifacts: true
3861

3962
## setup vault creds
4063
bootstrap:
@@ -54,6 +77,9 @@ bootstrap:
5477
- echo "PIP_EXTRA_INDEX_URL=https://${pypi_user}:${pypi_password}@$ARTIFACTORY_URL" >> build.env
5578
- echo "NVCR_REGISTRY_PASSWORD=$(vault read -field=password "${NVCR_TOKEN}")" >> build.env
5679
- echo "GHCR_REGISTRY_PASSWORD=$(vault read -field=pat "${GHCR_TOKEN}")" >> build.env
80+
- echo "GITLAB_USER=${GITLAB_USER}" >> build.env
81+
- echo "GITLAB_EMAIL=${GITLAB_USER}@exchange.nvidia.com" >> build.env
82+
- echo "GITLAB_TOKEN=$(vault kv get -field=password ${GITLAB_TOKEN_LOCATION})" >> build.env
5783
artifacts:
5884
access: none
5985
reports:
@@ -131,5 +157,101 @@ mirror-agent-image:
131157
done
132158
- docker --config . manifest create "${NVCR_REGISTRY_IMAGE}:${IMG_TAG}" ${IMAGE_TARGETS}
133159
- docker --config . manifest push "${NVCR_REGISTRY_IMAGE}:${IMG_TAG}"
134-
135-
160+
161+
create-operator-json:
162+
rules:
163+
- if: '$CI_COMMIT_TAG =~ /^operator\/v\d+\.\d+\.\d+$/'
164+
needs:
165+
- job: bootstrap
166+
artifacts: true
167+
script:
168+
- |
169+
export CI_COMMIT_TAG="operator/v1.0.0"
170+
cat > operator.json << EOF
171+
{
172+
"skyhook": {
173+
"source": {
174+
"org": "nvstaging",
175+
"team": "skyhook"
176+
},
177+
"target": {
178+
"org": "nvidia",
179+
"team": "skyhook"
180+
},
181+
"artifacts": [
182+
{
183+
"name": "operator",
184+
"version": "${CI_COMMIT_TAG#operator/}",
185+
"type": "container"
186+
}
187+
]
188+
}
189+
}
190+
EOF
191+
artifacts:
192+
paths:
193+
- operator.json
194+
195+
create-agent-json:
196+
rules:
197+
- if: '$CI_COMMIT_TAG =~ /^agent\/v\d+\.\d+\.\d+$/'
198+
needs:
199+
- job: bootstrap
200+
artifacts: true
201+
script:
202+
- |
203+
export CI_COMMIT_TAG="agent/v1.0.0"
204+
cat > agent.json << EOF
205+
{
206+
"skyhook": {
207+
"source": {
208+
"org": "${NGC_PRIVATE_ORG}",
209+
"team": "skyhook"
210+
},
211+
"target": {
212+
"org": "nvidia",
213+
"team": "skyhook"
214+
},
215+
"artifacts": [
216+
{
217+
"name": "agent",
218+
"version": "${CI_COMMIT_TAG#agent/}",
219+
"type": "container"
220+
}
221+
]
222+
}
223+
}
224+
EOF
225+
artifacts:
226+
paths:
227+
- agent.json
228+
229+
assemble-artifacts:
230+
needs:
231+
- job: create-operator-json
232+
optional: true
233+
artifacts: true
234+
- job: create-agent-json
235+
optional: true
236+
artifacts: true
237+
rules:
238+
- if: '$CI_COMMIT_TAG =~ /^(operator|agent)\/v\d+\.\d+\.\d+$/'
239+
before_script:
240+
- apt update
241+
- apt install -y jq
242+
script:
243+
- |
244+
if [ -f operator.json ] && [ -f agent.json ]; then
245+
# Merge both JSON files
246+
jq -s '.[0].skyhook.artifacts += .[1].skyhook.artifacts | .[0]' operator.json agent.json > artifacts.json
247+
elif [ -f operator.json ]; then
248+
cp operator.json artifacts.json
249+
elif [ -f agent.json ]; then
250+
cp agent.json artifacts.json
251+
else
252+
echo "No JSON files found"
253+
exit 1
254+
fi
255+
artifacts:
256+
paths:
257+
- artifacts.json

0 commit comments

Comments
 (0)