1- name : 🧭 Helm Chart PR Prerelease
1+ name : 🧭 Helm Chart Prerelease
22
33on :
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
921concurrency :
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
1325env :
5466
5567 prerelease :
5668 needs : lint-and-test
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'
5773 runs-on : ubuntu-latest
5874 permissions :
5975 contents : read
@@ -87,16 +103,35 @@ jobs:
87103 id : version
88104 run : |
89105 BASE_VERSION=$(grep '^version:' ./hosting/k8s/helm/Chart.yaml | awk '{print $2}')
90- PR_NUMBER=${{ github.event.pull_request.number }}
91- SHORT_SHA=$(echo "${{ github.event.pull_request.head.sha }}" | cut -c1-7)
92- 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
93121 echo "version=$PRERELEASE_VERSION" >> $GITHUB_OUTPUT
94122 echo "Prerelease version: $PRERELEASE_VERSION"
95123
96124 - name : Update Chart.yaml with prerelease version
97125 run : |
98126 sed -i "s/^version:.*/version: ${{ steps.version.outputs.version }}/" ./hosting/k8s/helm/Chart.yaml
99127
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+
100135 - name : Package Helm Chart
101136 run : |
102137 helm package ./hosting/k8s/helm/ --destination /tmp/
@@ -109,7 +144,23 @@ jobs:
109144 # Push to GHCR OCI registry
110145 helm push "$CHART_PACKAGE" "oci://${{ env.REGISTRY }}/${{ github.repository_owner }}/charts"
111146
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+
112162 - name : Find existing comment
163+ if : github.event_name == 'pull_request'
113164 uses : peter-evans/find-comment@v3
114165 id : find-comment
115166 with :
@@ -118,6 +169,7 @@ jobs:
118169 body-includes : " Helm Chart Prerelease Published"
119170
120171 - name : Create or update PR comment
172+ if : github.event_name == 'pull_request'
121173 uses : peter-evans/create-or-update-comment@v4
122174 with :
123175 comment-id : ${{ steps.find-comment.outputs.comment-id }}
0 commit comments