-
Notifications
You must be signed in to change notification settings - Fork 3
222 lines (186 loc) · 7.47 KB
/
chart.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
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
name: Helm Chart
on:
pull_request:
branches:
- main
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
PYTHON_VERSION: "3.9"
HELM_VERSION: v3.11.2
GHCR_REGISTRY: ghcr.io
ARTIFACT_REGISTRY: europe-north1-docker.pkg.dev
ARTIFACT_REPO: nais-io/nais/feature
SERVICE_ACCOUNT: gh-unleasherator@nais-io.iam.gserviceaccount.com
jobs:
meta:
name: Metadata Charts
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
name: ${{ steps.name.outputs.name }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- id: version
run: echo "version=$(date +'%Y%m%d')-$(git rev-parse --short HEAD)" >> ${GITHUB_OUTPUT}
- id: name
run: echo "name=${{ github.event.repository.name }}" >> ${GITHUB_OUTPUT}
- name: Update Chart.yaml
run: |
sed -i "s/^version:.*$/version: ${{ steps.version.outputs.version }}/g" ./charts/${{ steps.name.outputs.name }}/Chart.yaml
sed -i "s/^version:.*$/version: ${{ steps.version.outputs.version }}/g" ./charts/${{ steps.name.outputs.name }}-crds/Chart.yaml
sed -i "s/^appVersion:.*$/appVersion: ${{ steps.version.outputs.version }}/g" ./charts/${{ steps.name.outputs.name }}/Chart.yaml
sed -i "s/^appVersion:.*$/appVersion: ${{ steps.version.outputs.version }}/g" ./charts/${{ steps.name.outputs.name }}-crds/Chart.yaml
cat ./charts/${{ steps.name.outputs.name }}/Chart.yaml
- name: Update values.yaml
run: |
sed -i "s/^ tag: main$/ tag: ${{ steps.version.outputs.version }}/g" ./charts/${{ steps.name.outputs.name }}/values.yaml
cat ./charts/${{ steps.name.outputs.name }}/values.yaml
- name: Save Chart Metadata
uses: actions/upload-artifact@v4
with:
name: chart-metadata
path: |
./charts/${{ steps.name.outputs.name }}/Chart.yaml
- name: Save Chart Values
uses: actions/upload-artifact@v4
with:
name: chart-values
path: |
./charts/${{ steps.name.outputs.name }}/values.yaml
- name: Save CRDs Chart Metadata
uses: actions/upload-artifact@v4
with:
name: crds-chart-metadata
path: |
./charts/${{ steps.name.outputs.name }}-crds/Chart.yaml
lint-test:
name: Lint and test Charts
runs-on: ubuntu-latest-16-cores
needs: meta
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Restore Chart Metadata
uses: actions/download-artifact@v4.1.8
with:
name: chart-metadata
path: ./charts/${{ needs.meta.outputs.name }}
- name: Restore CRDs Chart Metadata
uses: actions/download-artifact@v4.1.8
with:
name: crds-chart-metadata
path: ./charts/${{ needs.meta.outputs.name }}-crds
- name: Set up Helm
uses: azure/setup-helm@v4
with:
version: ${{ env.HELM_VERSION }}
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
check-latest: true
- name: Set up chart-testing
uses: helm/chart-testing-action@v2.7.0
- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }})
if [[ -n "$changed" ]]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Run chart-testing (lint)
if: steps.list-changed.outputs.changed == 'true'
run: ct lint --target-branch ${{github.event.repository.default_branch }}
- name: Create kind cluster
if: steps.list-changed.outputs.changed == 'true'
uses: helm/kind-action@v1.12.0
- uses: docker/setup-buildx-action@v3
- uses: docker/metadata-action@v5
id: metadata
with:
images: |
${{ env.GHCR_REGISTRY }}/${{ github.repository }}
tags: |
type=raw,value=main
- uses: docker/build-push-action@v6
with:
context: .
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64
- name: Load image to kind
run: |
kind load docker-image ${{ env.GHCR_REGISTRY }}/${{ github.repository }}:main --name chart-testing
# Hack imagePullPolicy to never to avoid pulling during test install
sed -i "s/imagePullPolicy: Always/imagePullPolicy: Never/g" ./charts/${{ needs.meta.outputs.name }}/values.yaml
- name: Run chart-testing (install)
if: steps.list-changed.outputs.changed == 'true'
run: |
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
helm install prometheus-operator-crds prometheus-community/prometheus-operator-crds --wait
helm install unleasherator-crds ./charts/unleasherator-crds --wait
ct install --charts ./charts/unleasherator --target-branch ${{ github.event.repository.default_branch }}
push:
permissions:
contents: read
id-token: write
name: Build and push Charts
runs-on: ubuntu-latest
needs: [meta, lint-test]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Restore Chart Metadata
uses: actions/download-artifact@v4.1.8
with:
name: chart-metadata
path: ./charts/${{ needs.meta.outputs.name }}
- name: Restore Chart Values
uses: actions/download-artifact@v4.1.8
with:
name: chart-values
path: ./charts/${{ needs.meta.outputs.name }}
- name: Restore CRDs Chart Metadata
uses: actions/download-artifact@v4.1.8
with:
name: crds-chart-metadata
path: ./charts/${{ needs.meta.outputs.name }}-crds
- id: auth
if: github.actor != 'dependabot[bot]'
name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2.1.7
with:
workload_identity_provider: ${{ secrets.NAIS_IO_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ env.SERVICE_ACCOUNT }}
token_format: access_token
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
- name: Log in to Google Artifact Registry
if: github.actor != 'dependabot[bot]'
run: |
echo '${{ steps.auth.outputs.access_token }}' | docker login -u oauth2accesstoken --password-stdin https://${{ env.ARTIFACT_REGISTRY }}
- uses: azure/setup-helm@v4
name: Setup Helm
with:
version: ${{ env.HELM_VERSION }}
- name: Build Charts
run: |
helm package ./charts/${{ needs.meta.outputs.name }}-crds -d ./charts/${{ needs.meta.outputs.name }}-crds
helm package ./charts/${{ needs.meta.outputs.name }} -d ./charts/${{ needs.meta.outputs.name }}
- name: Push Charts
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
helm push ./charts/${{ needs.meta.outputs.name }}-crds/*.tgz oci://${{ env.ARTIFACT_REGISTRY }}/${{ env.ARTIFACT_REPO }}
helm push ./charts/${{ needs.meta.outputs.name }}/*.tgz oci://${{ env.ARTIFACT_REGISTRY }}/${{ env.ARTIFACT_REPO }}