-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yaml
67 lines (67 loc) · 2.13 KB
/
action.yaml
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
name: Publish Helm Chart
description: Package and publish Helm chart to an OCI registry
inputs:
registry:
description: The OCI registry to publish to
required: true
repository:
description: The repository within the registry to publish to
required: true
username:
description: Username used to authenticate with the registry
required: true
password:
description: Password used to authenticate with the registry
required: true
outputs:
chart:
description: The published chart including the tag
value: ${{steps.publish.outputs.pushed}}
runs:
using: composite
steps:
- name: Generate metadata
id: meta
shell: bash
run: |
echo "ociEndpoint=oci://${{inputs.registry}}/${{inputs.repository}}/" >> "$GITHUB_OUTPUT"
- name: Install Helm
uses: azure/setup-helm@v3
with:
version: 3.9.0
- name: Install yq
shell: bash
run: |
sudo wget -O /usr/local/bin/yq 'https://github.com/mikefarah/yq/releases/download/v4.27.2/yq_linux_amd64'
sudo chmod +x /usr/local/bin/yq
- name: Add dependency Helm repositories
shell: bash
run: |
i=0
for url in $(yq '.dependencies[].repository' Chart.yaml); do
[ "${url:0:6}" != "oci://" ] \
&& helm repo add "repo$i" "$url"
i=$((i+1))
done
- name: Authenticate Helm with the registry
shell: bash
run: |
printf "%s" '${{inputs.password}}' | helm registry login \
--password-stdin \
--username '${{inputs.username}}' \
"${{inputs.registry}}"
- name: Build dependencies
shell: bash
run: helm dependency build
- name: Package Helm chart
id: package
shell: bash
run: |
version="${GITHUB_REF_NAME#v}"
tarball="$(helm package . --version "$version" | sed -r 's/^[^:]+:\s+//')"
echo "tarball=$tarball" >> "$GITHUB_OUTPUT"
- name: Publish Helm chart
id: publish
shell: bash
run: |
helm push "${{steps.package.outputs.tarball}}" "${{steps.meta.outputs.ociEndpoint}}" | sed 's/^\([^:]*\):\s*/\L\1=/' >> "$GITHUB_OUTPUT"