-
-
Notifications
You must be signed in to change notification settings - Fork 620
309 lines (265 loc) Β· 11.7 KB
/
charts-release.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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
name: "Charts/Website: Build-and-Release"
concurrency:
group: ${{ github.head_ref }}-charts-website-release
on:
workflow_call:
workflow_dispatch:
#pull_request:
# paths:
# - "charts/**"
# - "website/**"
push:
branches:
- master
paths:
- "charts/**"
- "website/**"
- ".github/workflows/charts-release.yaml"
# Use `bash --noprofile --norc -exo pipefail` by default for all `run` steps in this workflow:
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#defaultsrun
defaults:
run:
shell: bash
jobs:
check_changes:
runs-on: ubuntu-latest
outputs:
changes_detected: ${{ steps.filter.outputs.changed }}
steps:
- name: Checkout code
uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2
- name: Filter paths
id: filter
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3
with:
list-files: json
filters: |
changed:
- 'website/**'
- '**/docs/**'
- '**/Chart.yaml'
release-helm:
permissions:
pull-requests: write
name: "${{ github.ref == 'refs/heads/master' && '(Production)' || '(Preview)' }}"
runs-on: actions-runners
needs: check_changes
steps:
- name: Checkout
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
with:
fetch-depth: 0
- name: Get Changelog Format Version
shell: bash
if: github.event_name == 'push'
run: |
ver=$(./charttool genchangelog format-version)
rev="1"
key="changelog-format-$ver-rev-$rev"
echo "Cache Key is: $key"
echo "CHANGELOG_CACHE_KEY=$key" >> $GITHUB_ENV
- name: Cache Changelog
id: cache-changelog
if: github.event_name == 'push'
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4
with:
key: ${{ env.CHANGELOG_CACHE_KEY }}-${{ hashFiles('**/Chart.yaml') }}
path: changelog.json.gz
restore-keys: |
${{ env.CHANGELOG_CACHE_KEY }}-${{ hashFiles('**/Chart.yaml') }}
${{ env.CHANGELOG_CACHE_KEY }}-
- name: Generate Changelog
shell: bash
if: github.event_name == 'push'
run: |
export REPO_PATH="./"
export TEMPLATE_PATH="./templates/CHANGELOG.md.tmpl"
export OUTPUT_DIR="./changelogs"
export JSON_FILE="changelog.json"
ls -l
if [ -f "$JSON_FILE.gz" ]; then
gunzip "$JSON_FILE.gz" --force # Force overwrite if file already exists
fi
./charttool genchangelog "$REPO_PATH" "$TEMPLATE_PATH" "$OUTPUT_DIR"
gzip "$JSON_FILE" --best
- name: Fix Pre-Commit issues
shell: bash
run: |
echo "Running pre-commit test-and-cleanup..."
pre-commit run --all ||:
# Fix sh files to always be executable
find . -name '*.sh' | xargs chmod +x
- name: Install Helm
uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # tag=v3
with:
version: v3.14.0
# Optional step if GPG signing is used
- name: Prepare GPG key
if: github.event_name == 'push'
run: |
gpg_dir=.cr-gpg
mkdir "$gpg_dir"
keyring="$gpg_dir/secring.gpg"
base64 -d <<< "$GPG_KEYRING_BASE64" > "$keyring"
passphrase_file="$gpg_dir/passphrase"
echo "$GPG_PASSPHRASE" > "$passphrase_file"
echo "CR_PASSPHRASE_FILE=$passphrase_file" >> "$GITHUB_ENV"
echo "CR_KEYRING=$keyring" >> "$GITHUB_ENV"
env:
GPG_KEYRING_BASE64: "${{ secrets.GPG_KEYRING_BASE64 }}"
GPG_PASSPHRASE: "${{ secrets.GPG_PASSPHRASE }}"
- name: Helm | Login
if: github.event_name == 'push'
shell: bash
run: echo ${{ secrets.QUAY_SECRET }} | helm registry login -u ${{ secrets.QUAY_USER }} --password-stdin quay.io
- name: Release Charts
shell: bash
if: github.event_name == 'push'
env:
CR_SKIP_EXISTING: "true"
run: |
owner=$(cut -d '/' -f 1 <<< "$GITHUB_REPOSITORY")
repo=$(cut -d '/' -f 2 <<< "$GITHUB_REPOSITORY")
install="$RUNNER_TOOL_CACHE/cr/${{ inputs.version }}/$(uname -m)"
echo "$install" >> "$GITHUB_PATH"
./.github/scripts/cr.sh --quay-token "${{ secrets.QUAY_TOKEN }}" --instal-dir $install
- name: Helm | Logout
shell: bash
if: github.event_name == 'push'
run: helm registry logout quay.io
- name: Copy docs to website
if: needs.check_changes.outputs.changes_detected == 'true'
shell: bash
run: |
#!/bin/bash
echo "Maing sure directories exist..."
mkdir -p website/public/img/hotlink-ok/chart-icons || echo "chart-icons path already exists, continuing..."
mkdir -p website/public/img/hotlink-ok/chart-icons-small || echo "chart-icons-small path already exists, continuing..."
mkdir -p website/src/assets || echo "assets path already exists, continuing..."
./charttool genchartlist ./charts
mv charts.json website/src/assets/charts.json
echo "Copying changelogs to docs"
mkdir -p ./website/src/content/docs/charts/
mkdir -p ./changelogs
# Check if there are any directories in changelogs
if [ -n "$(find ./changelogs -mindepth 1 -type d)" ]; then
cp -r ./changelogs/** ./website/src/content/docs/charts/
else
echo "No directories in ./changelogs. Skipping copy."
fi
export DEBUG=false
export STRICT=true
go-yq --version
for item in charts/*/*/Chart.yaml; do
# TODO: Move all website docs structure generation to charttool
IFS='/' read -r -a chart_parts <<<"$item"
./.github/scripts/chart-docs.sh "${chart_parts[1]}/${chart_parts[2]}"
done
- name: Comment deploy start
if: github.event_name != 'push' && needs.check_changes.outputs.changes_detected == 'true'
continue-on-error: true
uses: mshick/add-pr-comment@b8f338c590a895d50bcbfa6c5859251edc8952fc # v2
with:
message-id: cloudflare-deploy
message: |
### π§ Deploy Preview building...
| Name | Link |
|---------------------|-------------------------------------------------------------------------------|
|π¨ Latest commit | ${{ github.sha }} |
|π Latest deploy log | https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} |
---
- name: Prefetch contributor icons
shell: bash
if: needs.check_changes.outputs.changes_detected == 'true'
run: |
#!/bin/bash
## Loop through each contributor
## TODO: reenable later
#while read -r contributor; do
# avatar_url=$(echo "$contributor" | grep -oP '"avatar_url": "\K[^"]+')
#
# # Download the image
# wget -q "$avatar_url" -O temp_avatar
#
# # Generate new filename with original extension
# new_filename="public/assets/contributors/$(basename "$avatar_url" | cut -d '?' -f 1)"
#
# echo "converting file: $avatar_url"
# EXT=${FILE##*.} # file extension
# QUALITY=75 # quality for the image
# # convert the image using cwebp and output a file with the extension replaced as .webp
# cwebp -mt -m 6 -q $QUALITY -resize 32 32 "temp_avatar" -o "${new_filename}.webp" &>/dev/null
# rm temp_avatar
#
#done < src/assets/contributors.json
- name: Setup astro Cache
if: needs.check_changes.outputs.changes_detected == 'true'
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4
with:
# Cache for build and optimized images.
key: astro-${{ hashFiles('website/package-lock.json') }}
path: ./website/.astro
restore-keys: astro-
- name: Setup npm Cache
if: needs.check_changes.outputs.changes_detected == 'true'
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4
with:
# Cache for npm
path: ~/website/.npm
key: npm-${{ hashFiles('website/package-lock.json') }}
restore-keys: npm-
- name: Setup node_modules Cache
id: modulescache
if: needs.check_changes.outputs.changes_detected == 'true'
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4
with:
# Cache for npm and optimized images.
path: ./website/node_modules
key: modules-${{ hashFiles('website/package-lock.json') }}
- name: Setup Node
if: needs.check_changes.outputs.changes_detected == 'true' && needs.check_changes.outputs.changes_detected == 'true'
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4
with:
node-version-file: ./website/.nvmrc
- name: Install Packages
if: steps.modulescache.outputs.cache-hit != 'true' && needs.check_changes.outputs.changes_detected == 'true'
run: cd website && npm ci
- name: Check
if: needs.check_changes.outputs.changes_detected == 'true'
run: cd website && npm run check
- name: Build
if: needs.check_changes.outputs.changes_detected == 'true'
run: cd website && npm run build
- name: Publish to Cloudflare Pages
if: needs.check_changes.outputs.changes_detected == 'true'
id: cloudflare
continue-on-error: true
uses: cloudflare/pages-action@f0a1cd58cd66095dee69bfa18fa5efd1dde93bca # v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
# By default Cloudflare marks `main` as the "production" branch.
# So when this workflow is pushed to refs/heads/main, we set the branch to `main`/"production".
branch: ${{ github.ref == 'refs/heads/master' && 'main' || github.head_ref }}
# The project name in Cloudflare
projectName: website
directory: ./website/build
wranglerVersion: "3"
- name: Comment deploy url
if: github.event_name != 'push' && needs.check_changes.outputs.changes_detected == 'true'
continue-on-error: true
uses: mshick/add-pr-comment@b8f338c590a895d50bcbfa6c5859251edc8952fc # v2
with:
message-id: cloudflare-deploy
message: |
### β
Deploy Preview ready!
| Name | Link |
|----------------------|-------------------------------------------------------------------------------|
|π¨ Latest commit | ${{ github.sha }} |
|π Latest deploy log | https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} |
|π Deploy Preview Url | [${{ steps.cloudflare.outputs.url }}](${{ steps.cloudflare.outputs.url }}) |
|π³ Environment | ${{ steps.cloudflare.outputs.environment }} |
---
- name: Release-and-Website Completed
if: needs.check_changes.outputs.changes_detected == 'true'
run: echo "DONE"