Skip to content

Commit fefe61f

Browse files
authored
ci(helm): roll prereleases on main pushes + manual trigger (#3461)
Today the helm prerelease workflow only fires on PRs that touch `hosting/k8s/helm/**`. Two consequences we ran into: 1. The `changeset-release/main` PR's prerelease comment goes stale once the release branch gets force-pushed without a helm-touching commit (the bot's `Chart.yaml` bump alone doesn't seem to refire the trigger reliably). 2. The release PR's chart references an `appVersion` (e.g. `v4.4.5`) whose Docker images don't exist until *after* merge + tag. So that prerelease chart can't actually be installed end-to-end. Renames the workflow to `helm-prerelease.yml` and adds two new triggers: - **`push: main`** with `paths: hosting/k8s/helm/**` -> rolling prereleases versioned `<base>-main.<sha>`. `appVersion` stays at whatever `Chart.yaml` has (i.e. last released), so installs pull real images. Tests that chart structure is deployable, even if the app code is one release behind. - **`workflow_dispatch`** with optional `app_version` input -> manually trigger a prerelease and optionally override `appVersion` (e.g. pin to `main` or a specific tag). Useful for testing chart + app-version combinations on demand. PR behavior unchanged: same `<base>-pr<N>.<sha>` versioning, same posted/updated comment. Why not also bypass paths for `changeset-release/main`? The release PR's chart references not-yet-built `v4.4.5` images, so those prereleases aren't actually installable. The rolling main prerelease covers the testable case better. Why not SHA-pin `appVersion` to a built image like `main-<sha>`? Bigger change - the docker publish workflows currently only push `:main` (no SHA-suffixed tag). Worth doing later if we want first-class "install one chart, get exactly that commit's app code" testing, but out of scope here. Diff is mostly a rename. Substantive changes: - new `push` and `workflow_dispatch` triggers - `prerelease` job `if:` extended for the new event types - version logic branches per event - new "Override appVersion" step (workflow_dispatch only) - new "Write run summary" step so non-PR runs surface the install instructions - PR comment steps gated on `github.event_name == 'pull_request'` - concurrency group falls back to `github.ref` for non-PR runs
1 parent c69e939 commit fefe61f

3 files changed

Lines changed: 59 additions & 7 deletions

File tree

Lines changed: 57 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,35 @@ 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+
if [[ -z "$REF_SLUG" ]]; then
117+
REF_SLUG="manual"
118+
fi
119+
PRERELEASE_VERSION="${BASE_VERSION}-${REF_SLUG}.${SHORT_SHA}"
120+
fi
94121
echo "version=$PRERELEASE_VERSION" >> $GITHUB_OUTPUT
95122
echo "Prerelease version: $PRERELEASE_VERSION"
96123
97124
- name: Update Chart.yaml with prerelease version
98125
run: |
99126
sed -i "s/^version:.*/version: ${{ steps.version.outputs.version }}/" ./hosting/k8s/helm/Chart.yaml
100127
128+
- name: Override appVersion
129+
if: github.event_name == 'workflow_dispatch' && inputs.app_version != ''
130+
env:
131+
APP_VERSION: ${{ inputs.app_version }}
132+
run: |
133+
yq -i '.appVersion = strenv(APP_VERSION)' ./hosting/k8s/helm/Chart.yaml
134+
101135
- name: Package Helm Chart
102136
run: |
103137
helm package ./hosting/k8s/helm/ --destination /tmp/
@@ -110,7 +144,23 @@ jobs:
110144
# Push to GHCR OCI registry
111145
helm push "$CHART_PACKAGE" "oci://${{ env.REGISTRY }}/${{ github.repository_owner }}/charts"
112146
147+
- name: Write run summary
148+
run: |
149+
{
150+
echo "### 🧭 Helm Chart Prerelease Published"
151+
echo ""
152+
echo "**Version:** \`${{ steps.version.outputs.version }}\`"
153+
echo ""
154+
echo "**Install:**"
155+
echo '```bash'
156+
echo "helm upgrade --install trigger \\"
157+
echo " oci://${{ env.REGISTRY }}/${{ github.repository_owner }}/charts/${{ env.CHART_NAME }} \\"
158+
echo " --version \"${{ steps.version.outputs.version }}\""
159+
echo '```'
160+
} >> "$GITHUB_STEP_SUMMARY"
161+
113162
- name: Find existing comment
163+
if: github.event_name == 'pull_request'
114164
uses: peter-evans/find-comment@v3
115165
id: find-comment
116166
with:
@@ -119,6 +169,7 @@ jobs:
119169
body-includes: "Helm Chart Prerelease Published"
120170

121171
- name: Create or update PR comment
172+
if: github.event_name == 'pull_request'
122173
uses: peter-evans/create-or-update-comment@v4
123174
with:
124175
comment-id: ${{ steps.find-comment.outputs.comment-id }}

.github/workflows/pr_checks.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
- "docs/**"
88
- ".changeset/**"
99
- "hosting/**"
10+
- ".github/workflows/helm-prerelease.yml"
1011

1112
concurrency:
1213
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}

hosting/k8s/helm/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,4 +736,4 @@ helm upgrade --install trigger . \
736736
737737
- Documentation: https://trigger.dev/docs/self-hosting
738738
- GitHub Issues: https://github.com/triggerdotdev/trigger.dev/issues
739-
- Discord: https://discord.gg/untWVke9aH
739+
- Discord: https://discord.gg/untWVke9aH

0 commit comments

Comments
 (0)