41
41
CR_PACKAGE_PATH : " ${{ github.workspace }}/.cr-release-packages"
42
42
CR_TOOL_PATH : " ${{ github.workspace }}/.cr-tool"
43
43
HELM_TAG_PREFIX : " ${{ inputs.helm_tag_prefix }}"
44
+ REF_NAME : " ${{ github.ref_name }}"
44
45
45
46
jobs :
46
47
setup :
54
55
with :
55
56
fetch-depth : 0
56
57
path : source
58
+ persist-credentials : false
57
59
58
60
- name : Set up chart-testing
59
-
61
+ uses : helm/chart-testing-action@5f16c27cf7a4fa9c776ff73734df3909b2b65127 # v2.1.0
60
62
61
63
- name : List changed charts
62
64
id : list-changed
65
67
66
68
latest_tag=$( if ! git describe --tags --abbrev=0 2> /dev/null ; then git rev-list --max-parents=0 --first-parent HEAD ; fi )
67
69
68
- echo "Running: ct list-changed --config ${CT_CONFIGFILE} --since ${latest_tag} --target-branch ${{ github.ref_name } }"
69
- changed=$(ct list-changed --config "${CT_CONFIGFILE}" --since "${latest_tag}" --target-branch "${{ github.ref_name } }")
70
+ echo "Running: ct list-changed --config ${CT_CONFIGFILE} --since ${latest_tag} --target-branch ${REF_NAME }"
71
+ changed=$(ct list-changed --config "${CT_CONFIGFILE}" --since "${latest_tag}" --target-branch "${REF_NAME }")
70
72
echo "${changed}"
71
73
num_changed=$(wc -l <<< ${changed})
72
74
if [[ "${num_changed}" -gt "1" ]] ; then
@@ -102,25 +104,29 @@ jobs:
102
104
steps :
103
105
- name : Create a GitHub App installation access token
104
106
if : env.github_app_id != ''
105
- uses : tibdex/github-app-token@v2
107
+ uses : tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
106
108
id : app-token
107
109
with :
108
- app_id : ${{ secrets. github_app_id } }
110
+ app_id : ${github_app_id}
109
111
private_key : ${{ secrets.github_app_pem }}
110
112
111
113
- name : Set the correct token (Github App or PAT)
114
+ env :
115
+ HELM_REPO_TOKEN : ${{ secrets.helm_repo_token }}
116
+ APP_TOKEN : ${{ steps.app-token.outputs.token }}
112
117
run : |
113
- if [[ "${{ env. github_app_id } }" == '' ]]; then
114
- echo "AUTHTOKEN=${{ secrets.helm_repo_token } }" >> $GITHUB_ENV
118
+ if [[ "${github_app_id}" == '' ]]; then
119
+ echo "AUTHTOKEN=${HELM_REPO_TOKEN }" >> $GITHUB_ENV
115
120
else
116
- echo "AUTHTOKEN=${{ steps.app-token.outputs.token } }" >> $GITHUB_ENV
121
+ echo "AUTHTOKEN=${APP_TOKEN }" >> $GITHUB_ENV
117
122
fi
118
123
119
124
- name : Checkout
120
125
uses : actions/checkout@v4
121
126
with :
122
127
fetch-depth : 0
123
128
path : source
129
+ persist-credentials : false
124
130
125
131
- name : Configure Git
126
132
run : |
@@ -136,6 +142,7 @@ jobs:
136
142
repository : grafana/helm-charts
137
143
path : helm-charts
138
144
token : ${{ env.AUTHTOKEN }}
145
+ persist-credentials : false
139
146
140
147
- name : Configure Git for helm-charts
141
148
run : |
@@ -144,15 +151,17 @@ jobs:
144
151
git config user.email "[email protected] "
145
152
146
153
- name : Install Helm
147
- uses : azure/setup-helm@v4
154
+ uses : azure/setup-helm@b9e51907a09c216f16ebe8536097933489208112 # v4.3.0
148
155
with :
149
156
version : v3.16.2
150
157
151
158
- name : Parse Chart.yaml
152
159
id : parse-chart
160
+ env :
161
+ CHARTPATH : ${{ needs.setup.outputs.chartpath }}
153
162
run : |
154
163
cd source
155
- changed="${{ needs.setup.outputs.chartpath } }"
164
+ changed="${CHARTPATH }"
156
165
description=$(yq ".description" < ${changed}/Chart.yaml)
157
166
name=$(yq ".name" < ${changed}/Chart.yaml)
158
167
version=$(yq ".version" < ${changed}/Chart.yaml)
@@ -166,10 +175,12 @@ jobs:
166
175
echo "packagename=${name}-${version}" >> $GITHUB_OUTPUT
167
176
168
177
- name : Add dependency chart repos
178
+ env :
179
+ CHARTPATH : ${{ steps.parse-chart.outputs.chartpath }}
169
180
run : |
170
181
cd source
171
182
# Skip the header line and make sure that tabs are expanded into spaces
172
- deps=$(helm dependency list "${{ steps.parse-chart.outputs.chartpath } }" | tail +2 | expand)
183
+ deps=$(helm dependency list "${CHARTPATH }" | tail +2 | expand)
173
184
while read -r row; do
174
185
IFS=' ' read -ra parts <<< "$row"
175
186
name="${parts[0]}"
@@ -190,20 +201,24 @@ jobs:
190
201
rm -f cr.tar.gz
191
202
192
203
- name : Create helm package
204
+ env :
205
+ CHARTPATH : ${{ steps.parse-chart.outputs.chartpath }}
193
206
run : |
194
207
cd source
195
- "${CR_TOOL_PATH}/cr" package "${{ steps.parse-chart.outputs.chartpath } }" --config "${CR_CONFIGFILE}" --package-path "${CR_PACKAGE_PATH}"
208
+ "${CR_TOOL_PATH}/cr" package "${CHARTPATH }" --config "${CR_CONFIGFILE}" --package-path "${CR_PACKAGE_PATH}"
196
209
echo "Result of chart package:"
197
210
ls -l "${CR_PACKAGE_PATH}"
198
211
199
212
- name : Create tag and check if exists on origin
213
+ env :
214
+ TAGNAME : ${{ steps.parse-chart.outputs.tagname }}
200
215
run : |
201
216
cd source
202
- echo "Making tag ${{ steps.parse-chart.outputs.tagname } }"
203
- git tag "${{ steps.parse-chart.outputs.tagname } }"
217
+ echo "Making tag ${TAGNAME }"
218
+ git tag "${TAGNAME }"
204
219
205
220
- name : Make github release
206
- uses : softprops/action-gh-release@v1
221
+ uses : softprops/action-gh-release@b21b43df682dab285bf5146c1955e7f3560805f8 # tags/ v1
207
222
with :
208
223
body : |
209
224
${{ steps.parse-chart.outputs.desc }}
@@ -219,18 +234,20 @@ jobs:
219
234
token : ${{ env.AUTHTOKEN }}
220
235
221
236
- name : Push release tag on origin
237
+ env :
238
+ TAGNAME : ${{ steps.parse-chart.outputs.tagname }}
222
239
run : |
223
240
cd source
224
- echo "Pushing tag ${{ steps.parse-chart.outputs.tagname } }"
225
- git push origin "${{ steps.parse-chart.outputs.tagname } }"
241
+ echo "Pushing tag ${TAGNAME }"
242
+ git push origin "${TAGNAME }"
226
243
227
244
- name : Update helm repo index.yaml
228
245
run : |
229
246
cd helm-charts
230
247
"${CR_TOOL_PATH}/cr" index --config "${CR_CONFIGFILE}" --token "${{ env.AUTHTOKEN }}" --index-path "${CR_INDEX_PATH}" --package-path "${CR_PACKAGE_PATH}" --push
231
248
232
249
- name : Login to GHCR
233
-
250
+ uses : docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
234
251
with :
235
252
registry : ghcr.io
236
253
username : ${{ github.actor }}
@@ -239,5 +256,7 @@ jobs:
239
256
password : ${{ secrets.GITHUB_TOKEN }}
240
257
241
258
- name : Push charts to GHCR
259
+ env :
260
+ PACKAGENAME : ${{ steps.parse-chart.outputs.packagename }}
242
261
run : |
243
- helm push "${{ env. CR_PACKAGE_PATH }} /${{ steps.parse-chart.outputs.packagename } }.tgz" "oci://ghcr.io/${GITHUB_REPOSITORY_OWNER}/helm-charts"
262
+ helm push "${CR_PACKAGE_PATH} /${PACKAGENAME }.tgz" "oci://ghcr.io/${GITHUB_REPOSITORY_OWNER}/helm-charts"
0 commit comments