-
Notifications
You must be signed in to change notification settings - Fork 0
96 lines (86 loc) · 3.11 KB
/
chart-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
name: Release Charts
on:
release:
types: [published]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
check-chart-released:
runs-on: [ARM64, self-hosted, Linux]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check Release
id: chart_released
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const path = require('path');
const result = /refs\/tags\/(.*)-v[0-9.]+/.exec(context.ref)
if (result && result.length >= 2) {
const releaseName = result[1];
core.setOutput("released", fs.existsSync(path.join(releaseName, 'Chart.yaml')));
core.setOutput("release_name", releaseName);
} else {
core.setOutput("released", false);
}
outputs:
chart_released: ${{ steps.chart_released.outputs.released }}
release_name: ${{ steps.chart_released.outputs.release_name }}
release:
if: ${{ needs.check-chart-released.outputs.chart_released == 'true' }}
needs:
- check-chart-released
runs-on: [ARM64, self-hosted, Linux]
steps:
- name: Parse Tag
id: parse_tag
uses: actions/github-script@v7
with:
result-encoding: string
script: return context.ref.replace('refs/tags/', '')
- name: Generate token
id: generate_token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.CZI_RELEASE_PLEASE_APP_ID }}
private_key: ${{ secrets.CZI_RELEASE_PLEASE_PK }}
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: artifacts
token: ${{ steps.generate_token.outputs.token }}
- uses: azure/setup-helm@v4
with:
version: '3.15.2'
id: install
- name: Publish charts
run: |
set -ue
set -o pipefail
# the index.yaml file will be hosted by the github pages site
INDEX_DIR="${GITHUB_WORKSPACE}"
# the location of the chart package
CHARTS_DIR="${GITHUB_WORKSPACE}/${{ needs.check-chart-released.outputs.release_name }}"
# location of release to download the chart from
CHART_DOWNLOAD_URL="https://github.com/${{ github.repository }}/raw/artifacts"
git config --global user.email "[email protected]"
git config --global user.name "CZI Argus Helm Publisher Bot"
echo ------
cat ${INDEX_DIR}/index.yaml
echo ------
git pull
git merge origin/main
echo ------
cat ${CHARTS_DIR}/Chart.yaml
echo ------
PACKAGE_DIR="."
helm dependency update ${PACKAGE_DIR}
helm package ${CHARTS_DIR} -d ${PACKAGE_DIR}
helm repo index ${PACKAGE_DIR} --url ${CHART_DOWNLOAD_URL} --merge ${INDEX_DIR}/index.yaml
git add -A
git commit -m "chore: publish charts from ${{ github.repository }} ${{ steps.parse_tag.outputs.result }}"
git push