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