Skip to content

Commit fb02ff7

Browse files
authored
Merge pull request #7 from appthrust/fix-gha3
ci(release-helm): Add Helm chart existence check before push
2 parents cdbfd0c + 7b99246 commit fb02ff7

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

.github/workflows/release-helm.yml

+11-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
version=$(yq e '.version' "$path/Chart.yaml")
2626
echo "{\"path\": \"$path\", \"name\": \"$name\", \"version\": \"$version\"}"
2727
done | jq -s -c)
28-
echo "charts=${CHARTS_JSON}" | tee -a "$GITHUB_OUTPUT"
28+
echo "charts=${CHARTS_JSON}" >> "$GITHUB_OUTPUT"
2929
3030
push-chart:
3131
needs: [plan]
@@ -48,11 +48,17 @@ jobs:
4848
- name: Helm login
4949
run: echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io -u ${{ github.repository_owner }} --password-stdin
5050

51-
- name: Package Helm Chart
51+
- name: Check if Helm Chart Exists
52+
id: check-existence
5253
run: |
53-
helm package ${{ matrix.charts.path }} --destination packaged
54+
if helm pull oci://ghcr.io/appthrust/charts/${{ matrix.charts.name }} --version ${{ matrix.charts.version }}; then
55+
echo "chart_exists=true" >> $GITHUB_ENV
56+
else
57+
echo "chart_exists=false" >> $GITHUB_ENV
58+
fi
5459
5560
- name: Push Helm Chart to GHCR
61+
if: env.chart_exists == 'false'
5662
run: |
57-
CHART_FILE=packaged/${{ matrix.charts.name }}-${{ matrix.charts.version }}.tgz
58-
helm push $CHART_FILE oci://ghcr.io/appthrust/charts
63+
helm package ${{ matrix.charts.path }} --destination packaged
64+
helm push packaged/${{ matrix.charts.name }}-${{ matrix.charts.version }}.tgz oci://ghcr.io/appthrust/charts

0 commit comments

Comments
 (0)