Skip to content

Commit 64714d6

Browse files
authored
Merge pull request #2524 from rahulait/release-helm-chart-workflow
add workflow for adding helm chart as oci artifact for commits
2 parents 27b9f65 + add306d commit 64714d6

3 files changed

Lines changed: 114 additions & 2 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ jobs:
7676
permissions:
7777
contents: read
7878
id-token: write
79+
packages: write
7980
uses: ./.github/workflows/e2e-tests.yaml
8081
with:
8182
operator_image: ${{ needs.variables.outputs.operator_image }}

.github/workflows/e2e-tests.yaml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,18 @@ jobs:
6262
operator_image: ${{ inputs.operator_image }}
6363
operator_version: ${{ inputs.operator_version }}
6464

65-
e2e-tests-containerd:
65+
publish-helm-oci-chart:
6666
needs: [variables]
67+
permissions:
68+
contents: read
69+
packages: write
70+
uses: ./.github/workflows/publish-helm-oci-chart.yaml
71+
with:
72+
operator_image: ${{ needs.variables.outputs.operator_image }}
73+
operator_version: ${{ needs.variables.outputs.operator_version }}
74+
75+
e2e-tests-containerd:
76+
needs: [variables, publish-helm-oci-chart]
6777
runs-on: linux-amd64-cpu4
6878
timeout-minutes: 90
6979
permissions:
@@ -129,7 +139,7 @@ jobs:
129139
retention-days: 15
130140

131141
e2e-tests-nvidiadriver:
132-
needs: [variables]
142+
needs: [variables, publish-helm-oci-chart]
133143
runs-on: linux-amd64-cpu4
134144
timeout-minutes: 90
135145
permissions:
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Copyright NVIDIA CORPORATION
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: Publish Helm OCI Chart
16+
17+
on:
18+
workflow_call:
19+
inputs:
20+
operator_image:
21+
required: true
22+
type: string
23+
operator_version:
24+
required: true
25+
type: string
26+
27+
permissions:
28+
contents: read
29+
packages: write
30+
31+
concurrency:
32+
group: publish-helm-oci-chart-${{ inputs.operator_version }}
33+
cancel-in-progress: false
34+
35+
jobs:
36+
publish-helm-chart:
37+
runs-on: ubuntu-latest
38+
timeout-minutes: 10
39+
steps:
40+
- uses: actions/checkout@v6
41+
name: Check out code
42+
43+
- name: Set up Helm
44+
uses: azure/setup-helm@v5.0.0
45+
46+
- name: Set chart image repository
47+
env:
48+
OPERATOR_IMAGE: ${{ inputs.operator_image }}
49+
run: echo "OPERATOR_REPOSITORY=${OPERATOR_IMAGE%/*}" >> "${GITHUB_ENV}"
50+
51+
- name: Update chart image repository
52+
uses: mikefarah/yq@v4
53+
with:
54+
cmd: yq -i '.operator.repository = env(OPERATOR_REPOSITORY) | .validator.repository = env(OPERATOR_REPOSITORY)' deployments/gpu-operator/values.yaml
55+
56+
- name: Login to GitHub Container Registry
57+
env:
58+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
run: echo "${GH_TOKEN}" | helm registry login ghcr.io -u "${GITHUB_ACTOR}" --password-stdin
60+
61+
- name: Package Helm chart
62+
id: package
63+
env:
64+
OPERATOR_VERSION: ${{ inputs.operator_version }}
65+
run: |
66+
set -euo pipefail
67+
68+
# Helm chart versions must be SemVer. Prefix the image version so a
69+
# numeric short SHA with a leading zero remains a valid prerelease.
70+
CHART_VERSION="0.0.0-git-${OPERATOR_VERSION}"
71+
72+
mkdir -p dist
73+
helm lint deployments/gpu-operator
74+
helm package \
75+
--version "${CHART_VERSION}" \
76+
--app-version "${OPERATOR_VERSION}" \
77+
--destination dist \
78+
deployments/gpu-operator
79+
80+
CHART_PACKAGE="$(find dist -maxdepth 1 -type f -name 'gpu-operator-*.tgz' | head -n 1)"
81+
if [[ -z "${CHART_PACKAGE}" ]]; then
82+
echo "::error::Helm chart package was not created"
83+
exit 1
84+
fi
85+
86+
echo "chart_package=${CHART_PACKAGE}" >> "${GITHUB_OUTPUT}"
87+
echo "chart_version=${CHART_VERSION}" >> "${GITHUB_OUTPUT}"
88+
89+
- name: Publish Helm OCI chart
90+
env:
91+
GITHUB_REPOSITORY_OWNER: ${{ github.repository_owner }}
92+
CHART_PACKAGE: ${{ steps.package.outputs.chart_package }}
93+
CHART_VERSION: ${{ steps.package.outputs.chart_version }}
94+
run: |
95+
set -euo pipefail
96+
97+
LOWERCASE_REPO_OWNER=$(echo "${GITHUB_REPOSITORY_OWNER}" | awk '{print tolower($0)}')
98+
CHART_REPOSITORY="oci://ghcr.io/${LOWERCASE_REPO_OWNER}/gpu-operator/charts"
99+
100+
helm push "${CHART_PACKAGE}" "${CHART_REPOSITORY}"
101+
echo "::notice::Published Helm chart to ${CHART_REPOSITORY}/gpu-operator:${CHART_VERSION}"

0 commit comments

Comments
 (0)