-
Notifications
You must be signed in to change notification settings - Fork 0
156 lines (130 loc) · 4.79 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
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
ARTIFACT_REGISTRY: europe-north1-docker.pkg.dev
ARTIFACT_REPO: nais-io/nais/feature
SERVICE_ACCOUNT: [email protected]
jobs:
meta:
name: Metadata
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/^appVersion:.*$/appVersion: ${{ steps.version.outputs.version }}/g" ./charts/${{ steps.name.outputs.name }}/Chart.yaml
cat ./charts/${{ steps.name.outputs.name }}/Chart.yaml
- name: Update values.yaml
run: |
sed -i "s/^ tag:.*$/ 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
./charts/${{ steps.name.outputs.name }}/values.yaml
lint-test:
name: Lint and test Chart
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
with:
name: chart-metadata
path: ./charts/${{ needs.meta.outputs.name }}
- 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
- 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/[email protected]
# - name: Run chart-testing (install)
# if: steps.list-changed.outputs.changed == 'true'
# run: |
# helm install bifrost ./charts/bifrost --wait
# ct install --charts ./charts/bifrost --target-branch ${{ github.event.repository.default_branch }}
push:
permissions:
contents: read
id-token: write
name: Build and push Chart
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
with:
name: chart-metadata
path: ./charts/${{ needs.meta.outputs.name }}
- id: auth
if: github.actor != 'dependabot[bot]'
name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
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 Chart
run: |
helm package ./charts/${{ needs.meta.outputs.name }} -d ./charts
- name: Push Chart
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
helm push ./charts/*.tgz oci://${{ env.ARTIFACT_REGISTRY }}/${{ env.ARTIFACT_REPO }}