Skip to content

Commit 420aa12

Browse files
committed
ci(helm): roll prereleases on main pushes + manual trigger
Renames helm-pr-prerelease.yml to helm-prerelease.yml. The workflow now also runs on main pushes (paths: hosting/k8s/helm/**) so the chart doesn't go stale between releases, and supports workflow_dispatch with an optional appVersion override for manual builds. Behavior: - pull_request: <base>-pr<N>.<sha>, posts/updates a PR comment as before - push to main: <base>-main.<sha>, summary written to run page - workflow_dispatch: <base>-<ref-slug>.<sha>, optional appVersion override
1 parent c69e939 commit 420aa12

1 file changed

Lines changed: 52 additions & 6 deletions

File tree

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
1-
name: 🧭 Helm Chart PR Prerelease
1+
name: 🧭 Helm Chart Prerelease
22

33
on:
44
pull_request:
55
types: [opened, synchronize, reopened]
66
paths:
77
- "hosting/k8s/helm/**"
8+
push:
9+
branches:
10+
- main
11+
paths:
12+
- "hosting/k8s/helm/**"
13+
workflow_dispatch:
14+
inputs:
15+
app_version:
16+
description: "Override appVersion (e.g. 'main', 'v4.4.4'). Leave empty to keep Chart.yaml value."
17+
required: false
18+
type: string
19+
default: ""
820

921
concurrency:
10-
group: helm-prerelease-${{ github.event.pull_request.number }}
22+
group: helm-prerelease-${{ github.event.pull_request.number || github.ref }}
1123
cancel-in-progress: true
1224

1325
env:
@@ -54,7 +66,10 @@ jobs:
5466

5567
prerelease:
5668
needs: lint-and-test
57-
if: github.event.pull_request.head.repo.full_name == github.repository
69+
if: |
70+
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) ||
71+
github.event_name == 'push' ||
72+
github.event_name == 'workflow_dispatch'
5873
runs-on: ubuntu-latest
5974
permissions:
6075
contents: read
@@ -88,16 +103,30 @@ jobs:
88103
id: version
89104
run: |
90105
BASE_VERSION=$(grep '^version:' ./hosting/k8s/helm/Chart.yaml | awk '{print $2}')
91-
PR_NUMBER=${{ github.event.pull_request.number }}
92-
SHORT_SHA=$(echo "${{ github.event.pull_request.head.sha }}" | cut -c1-7)
93-
PRERELEASE_VERSION="${BASE_VERSION}-pr${PR_NUMBER}.${SHORT_SHA}"
106+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
107+
PR_NUMBER=${{ github.event.pull_request.number }}
108+
SHORT_SHA=$(echo "${{ github.event.pull_request.head.sha }}" | cut -c1-7)
109+
PRERELEASE_VERSION="${BASE_VERSION}-pr${PR_NUMBER}.${SHORT_SHA}"
110+
elif [[ "${{ github.event_name }}" == "push" ]]; then
111+
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
112+
PRERELEASE_VERSION="${BASE_VERSION}-main.${SHORT_SHA}"
113+
else
114+
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
115+
REF_SLUG=$(echo "${{ github.ref_name }}" | tr '/' '-' | tr -cd 'a-zA-Z0-9-')
116+
PRERELEASE_VERSION="${BASE_VERSION}-${REF_SLUG}.${SHORT_SHA}"
117+
fi
94118
echo "version=$PRERELEASE_VERSION" >> $GITHUB_OUTPUT
95119
echo "Prerelease version: $PRERELEASE_VERSION"
96120
97121
- name: Update Chart.yaml with prerelease version
98122
run: |
99123
sed -i "s/^version:.*/version: ${{ steps.version.outputs.version }}/" ./hosting/k8s/helm/Chart.yaml
100124
125+
- name: Override appVersion
126+
if: github.event_name == 'workflow_dispatch' && inputs.app_version != ''
127+
run: |
128+
sed -i "s/^appVersion:.*/appVersion: ${{ inputs.app_version }}/" ./hosting/k8s/helm/Chart.yaml
129+
101130
- name: Package Helm Chart
102131
run: |
103132
helm package ./hosting/k8s/helm/ --destination /tmp/
@@ -110,7 +139,23 @@ jobs:
110139
# Push to GHCR OCI registry
111140
helm push "$CHART_PACKAGE" "oci://${{ env.REGISTRY }}/${{ github.repository_owner }}/charts"
112141
142+
- name: Write run summary
143+
run: |
144+
{
145+
echo "### 🧭 Helm Chart Prerelease Published"
146+
echo ""
147+
echo "**Version:** \`${{ steps.version.outputs.version }}\`"
148+
echo ""
149+
echo "**Install:**"
150+
echo '```bash'
151+
echo "helm upgrade --install trigger \\"
152+
echo " oci://${{ env.REGISTRY }}/${{ github.repository_owner }}/charts/${{ env.CHART_NAME }} \\"
153+
echo " --version \"${{ steps.version.outputs.version }}\""
154+
echo '```'
155+
} >> "$GITHUB_STEP_SUMMARY"
156+
113157
- name: Find existing comment
158+
if: github.event_name == 'pull_request'
114159
uses: peter-evans/find-comment@v3
115160
id: find-comment
116161
with:
@@ -119,6 +164,7 @@ jobs:
119164
body-includes: "Helm Chart Prerelease Published"
120165

121166
- name: Create or update PR comment
167+
if: github.event_name == 'pull_request'
122168
uses: peter-evans/create-or-update-comment@v4
123169
with:
124170
comment-id: ${{ steps.find-comment.outputs.comment-id }}

0 commit comments

Comments
 (0)