-
Notifications
You must be signed in to change notification settings - Fork 0
47 lines (45 loc) · 1.77 KB
/
helm-publish.yaml
File metadata and controls
47 lines (45 loc) · 1.77 KB
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
name: Publish Helm Chart (OCI)
on:
push:
paths:
- "deploy/charts/sdb-controller/Chart.yaml"
jobs:
publish:
if: contains(github.event.head_commit.message, '[skip chart]') == false
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: azure/setup-helm@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install yq
uses: mikefarah/yq@v4.48.1
with:
cmd: yq --version
- name: Login to GHCR
run: echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Detect version change
id: ver
run: |
CHART=deploy/charts/sdb-controller
VERSION=$(yq -r .version "$CHART/Chart.yaml")
echo "version=$VERSION" >> $GITHUB_OUTPUT
if ! git show HEAD^:"$CHART/Chart.yaml" >/dev/null 2>&1; then echo "changed=true" >> $GITHUB_OUTPUT; exit 0; fi
PREV=$(git show HEAD^:"$CHART/Chart.yaml" | yq -r .version)
if [ "$VERSION" != "$PREV" ]; then echo "changed=true" >> $GITHUB_OUTPUT; else echo "changed=false" >> $GITHUB_OUTPUT; fi
- name: Package chart
if: steps.ver.outputs.changed == 'true'
run: |
CHART=deploy/charts/sdb-controller
VERSION=$(yq -r .version "$CHART/Chart.yaml")
helm dependency update "$CHART" || true
helm package "$CHART" --version "$VERSION" -d dist
- name: Push chart
if: steps.ver.outputs.changed == 'true'
run: |
CHART=deploy/charts/sdb-controller
VERSION=$(yq -r .version "$CHART/Chart.yaml")
helm push dist/sdb-controller-$VERSION.tgz oci://ghcr.io/${{ github.repository_owner }}/charts