generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 4
152 lines (130 loc) · 4.44 KB
/
publish-helm.yml
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
name: Publish Helm
on:
workflow_dispatch
env:
HELM_VERSION: v3.11.3
REGISTRY: ghcr.io
CHART_DIRECTORY: chart
RELEASE_TAG_PREFIX: helm
jobs:
create_release_tag:
name: Create release tag
runs-on: ubuntu-22.04
outputs:
tag: ${{ steps.get_tag.outputs.tag }}
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: azure/setup-helm@v4
with:
version: ${{ env.HELM_VERSION }}
- name: Determine target commit
id: get_target_commit
run: |
sha=$(git rev-parse HEAD)
echo "Target commit: $sha"
echo "sha=$sha" >> $GITHUB_OUTPUT
- name: Get tag
id: get_tag
run: |
chart_version=$(yq .version $CHART_DIRECTORY/Chart.yaml)
echo "tag=$RELEASE_TAG_PREFIX/$chart_version" >> $GITHUB_OUTPUT
- name: Wait for check suites to complete
uses: sap-contributions/await-check-suites@master
with:
ref: ${{ steps.get_target_commit.outputs.sha }}
intervalSeconds: 10
timeoutSeconds: 1800
failStepIfUnsuccessful: true
appSlugFilter: github-actions
- name: Create release
id: create_release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.get_tag.outputs.tag }}
commit: ${{ steps.get_target_commit.outputs.sha }}
makeLatest: false
prerelease: false
allowUpdates: false
publish-to-pages:
name: Publish chart to github pages
runs-on: ubuntu-22.04
needs: create_release_tag
permissions:
contents: write
pages: write
id-token: write
environment:
name: github-pages
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: website
path: website
token: ${{ secrets.WORKFLOW_USER_TOKEN }}
- uses: azure/setup-helm@v3
with:
version: ${{ env.HELM_VERSION }}
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Create package
run: |
chart_version=$(yq .version $CHART_DIRECTORY/Chart.yaml)
helm package --version $chart_version $CHART_DIRECTORY
- name: Create index
run: |
helm repo index --url ${{ github.server_url }}/${{ github.repository }}/releases/download/${{ needs.create_release_tag.outputs.tag }} --merge ./website/static/index.yaml .
mv index.yaml website/static
cd website
git config user.name "${{ vars.WORKFLOW_USER_NAME }}"
git config user.email "${{ vars.WORKFLOW_USER_EMAIL }}"
git add .
git commit -m "Add index.yaml to website"
git push
- name: Upload package
run: |
upload_url="${{ needs.create_release_tag.outputs.upload_url }}"
upload_url=${upload_url%%\{*\}}
chart_name=$(yq .name $CHART_DIRECTORY/Chart.yaml)
chart_version=$(yq .version $CHART_DIRECTORY/Chart.yaml)
file=$chart_name-$chart_version.tgz
echo "Uploading $file to $upload_url ..."
curl -sSf \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ github.token }}" \
-H "Content-Type: $(file -b --mime-type $file)" \
--data-binary @$file \
"$upload_url?name=$(basename $file)"
publish-to-packages:
name: Publish chart to github packages
needs: create_release_tag
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: azure/setup-helm@v4
with:
version: ${{ env.HELM_VERSION }}
- name: Create package
run: |
chart_version=$(yq .version $CHART_DIRECTORY/Chart.yaml)
helm package --version $chart_version $CHART_DIRECTORY
- name: Login to the OCI registry
run: |
helm --registry-config $RUNNER_TEMP/helm-config.json registry login $REGISTRY -u ${{ github.actor }} --password-stdin <<< ${{ github.token }}
- name: Upload package
run: |
chart_name=$(yq .name $CHART_DIRECTORY/Chart.yaml)
chart_version=$(yq .version $CHART_DIRECTORY/Chart.yaml)
file=$chart_name-$chart_version.tgz
repository=$REGISTRY/${{ github.repository }}/$RELEASE_TAG_PREFIX
helm --registry-config $RUNNER_TEMP/helm-config.json push $file oci://${repository,,}