-
Notifications
You must be signed in to change notification settings - Fork 0
201 lines (170 loc) · 6.61 KB
/
helm-charts.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
name: Helm Charts
on:
push:
branches:
- main
- releases/**
pull_request:
workflow_dispatch:
jobs:
vars:
name: Variables
# This is a work-around to be able to properly use variables.
# This job should be made a dependency in order to be able to use its outputs.
runs-on: ubuntu-latest
outputs:
is_main_branch: ${{ github.ref_type == 'branch' && github.ref_name == 'main' }}
is_release_branch: ${{ github.ref_type == 'branch' && startsWith(github.ref_name, 'releases/') }}
is_pull_request: ${{ github.event_name == 'pull_request' }}
target_branch: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || github.ref_name }}
charts: ${{ steps.list-charts.outputs.charts }}
app_charts: ${{ steps.list-app-charts.outputs.charts }}
lib_charts: ${{ steps.list-lib-charts.outputs.charts }}
lib_chart_names: ${{ steps.list-lib-charts.outputs.chart_names }}
timeout-minutes: 1
steps:
- name: Expose variables
run: echo "Exposing variables for proper usage"
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- name: List charts
id: list-charts
run: echo "charts=$(./bin/list-charts -p)" >> $GITHUB_OUTPUT
- name: List application charts
id: list-app-charts
run: echo "charts=$(./bin/list-charts -a -p)" >> $GITHUB_OUTPUT
- name: List library charts
id: list-lib-charts
run: |
echo "charts=$(./bin/list-charts -l -p)" >> $GITHUB_OUTPUT
echo "chart_names=$(./bin/list-charts -l -n)" >> $GITHUB_OUTPUT
lint-charts:
name: Lint Charts
needs:
- vars
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: ${{ needs.vars.outputs.is_pull_request == 'true' && '0' || '1' }}
- name: Set up Helm
uses: azure/setup-helm@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up python
uses: actions/setup-python@v5
with:
python-version: '3.9'
check-latest: true
- name: Set up chart-testing
uses: helm/[email protected]
- name: Add helm repositories
run: ./bin/add-repos
- name: List changed
id: list-changed
run: |
changed_charts="${{ needs.vars.outputs.charts }}"
if [ "${{ needs.vars.outputs.is_pull_request }}" == "true" ]; then
changed_charts="$(ct list-changed --config etc/ct.yaml --target-branch ${{ needs.vars.outputs.target_branch }})"
fi
if [[ -n "${changed_charts}" ]]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
else
echo "changed=false" >> "$GITHUB_OUTPUT"
fi
- name: Prepare library charts
if: ${{ steps.list-changed.outputs.changed == 'true' }}
run: |
lib_charts="${{ needs.vars.outputs.lib_charts }}"
for lc in ${lib_charts//,/ } ; do
# Add values.yaml file so the linter doesn't complain
echo "${lc}/values.yaml"
touch "${lc}/values.yaml"
done
- name: Lint charts
if: ${{ steps.list-changed.outputs.changed == 'true' }}
run: ct lint --config etc/ct.yaml ${{ needs.vars.outputs.is_pull_request == 'true' && format('--target-branch "{0}"', needs.vars.outputs.target_branch) || format('--charts "{0}"', needs.vars.outputs.charts) }}
test-charts:
name: Test Charts
needs:
- vars
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: ${{ needs.vars.outputs.is_pull_request == 'true' && '0' || '1' }}
- name: Set up Helm
uses: azure/setup-helm@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up python
uses: actions/setup-python@v5
with:
python-version: '3.9'
check-latest: true
- name: Set up chart-testing
uses: helm/[email protected]
- name: Add helm repositories
run: ./bin/add-repos
- name: List changed
id: list-changed
run: |
changed_charts="${{ needs.vars.outputs.app_charts }}"
if [ "${{ needs.vars.outputs.is_pull_request }}" == "true" ]; then
changed_charts="$(ct list-changed --config etc/ct.yaml --target-branch ${{ needs.vars.outputs.target_branch }})"
fi
if [[ -n "${changed_charts}" ]]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
else
echo "changed=false" >> "$GITHUB_OUTPUT"
fi
- name: Create kind cluster
if: ${{ steps.list-changed.outputs.changed == 'true' }}
uses: helm/[email protected]
- name: Test charts
if: ${{ steps.list-changed.outputs.changed == 'true' }}
run: ct install --config etc/ct.yaml ${{ needs.vars.outputs.is_pull_request == 'true' && format('--target-branch "{0}" --excluded-charts "{1}"', needs.vars.outputs.target_branch, needs.vars.outputs.lib_chart_names) || format('--charts "{0}"', needs.vars.outputs.app_charts) }}
release-charts:
name: Release Charts
if: ${{ needs.vars.outputs.is_main_branch == 'true' || needs.vars.outputs.is_release_branch == 'true' }}
needs:
- vars
- lint-charts
- test-charts
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Set git user
uses: git-actions/set-user@v1
- name: Install Helm
uses: azure/setup-helm@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Add helm repositories
run: ./bin/add-repos
- name: Run chart releaser
uses: helm/[email protected]
with:
config: etc/cr.yaml
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
release-please:
name: Release
if: ${{ needs.vars.outputs.is_main_branch == 'true' || needs.vars.outputs.is_release_branch == 'true' }}
# Run after release-charts so that the tag exists in case of release commits.
# Otherwise release please will create a new PR
# as it doesn't yet have the release to compare changes with.
needs:
- vars
- release-charts
permissions:
contents: write
pull-requests: write
uses: ./.github/workflows/release-please.yaml