-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (97 loc) · 3.21 KB
/
Copy pathhelm.yaml
File metadata and controls
115 lines (97 loc) · 3.21 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
name: helm
on:
pull_request:
paths:
- "charts/**"
- ".github/workflows/helm.yaml"
push:
branches:
- main
tags:
- "v*"
paths:
- "charts/**"
- ".github/workflows/helm.yaml"
workflow_dispatch:
permissions:
contents: read
packages: write
jobs:
package:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Helm
uses: azure/setup-helm@v4
- name: Compute package version
shell: bash
run: |
if [[ "${GITHUB_REF_TYPE}" == "tag" && "${GITHUB_REF_NAME}" == v* ]]; then
echo "CHART_VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_ENV"
fi
- name: Lint chart
run: helm lint ./charts
- name: Package chart
shell: bash
run: |
mkdir -p dist
if [[ -n "${CHART_VERSION:-}" ]]; then
helm package ./charts --destination dist --version "$CHART_VERSION" --app-version "$CHART_VERSION"
else
helm package ./charts --destination dist
fi
- name: Upload chart package
uses: actions/upload-artifact@v4
with:
name: helm-chart-package
path: dist/*.tgz
publish:
if: github.event_name == 'push'
needs: package
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Helm
uses: azure/setup-helm@v4
- name: Setup ORAS
uses: oras-project/setup-oras@v1
- name: Compute package version
shell: bash
run: |
if [[ "${GITHUB_REF_TYPE}" == "tag" && "${GITHUB_REF_NAME}" == v* ]]; then
echo "CHART_VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_ENV"
fi
- name: Package chart
shell: bash
run: |
mkdir -p dist
if [[ -n "${CHART_VERSION:-}" ]]; then
helm package ./charts --destination dist --version "$CHART_VERSION" --app-version "$CHART_VERSION"
else
helm package ./charts --destination dist
fi
- name: Compute OCI registry path
shell: bash
run: |
OWNER_LC="$(echo "${GITHUB_REPOSITORY_OWNER}" | tr '[:upper:]' '[:lower:]')"
echo "OCI_REPO=oci://ghcr.io/${OWNER_LC}/helm" >> "$GITHUB_ENV"
echo "OCI_REPO_PLAIN=ghcr.io/${OWNER_LC}/helm" >> "$GITHUB_ENV"
- name: Login to GHCR
run: echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io -u "${{ github.actor }}" --password-stdin
- name: Login to GHCR with ORAS
run: echo "${{ secrets.GITHUB_TOKEN }}" | oras login ghcr.io -u "${{ github.actor }}" --password-stdin
- name: Push chart to GHCR
shell: bash
run: |
helm push dist/*.tgz "$OCI_REPO"
- name: Tag main build as latest
if: github.ref == 'refs/heads/main'
shell: bash
run: |
CHART_NAME="$(helm show chart ./charts | awk '/^name:/ {print $2}')"
CHART_VERSION="$(helm show chart dist/*.tgz | awk '/^version:/ {print $2}')"
oras cp \
"${OCI_REPO_PLAIN}/${CHART_NAME}:${CHART_VERSION}" \
"${OCI_REPO_PLAIN}/${CHART_NAME}:latest"