77 description : ' Version to publish — must match an existing GitHub release (e.g., 3.8.0 or v3.8.0)'
88 required : true
99 type : string
10+ publish_oci :
11+ description : ' Push chart package to GHCR (OCI)'
12+ required : false
13+ default : true
14+ type : boolean
15+ update_github_pages :
16+ description : ' Update GitHub Pages Helm repo (gh-pages branch)'
17+ required : false
18+ default : true
19+ type : boolean
1020
1121permissions :
1222 contents : write
23+ packages : write
1324
1425jobs :
1526 validate-version :
@@ -141,10 +152,38 @@ jobs:
141152
142153 - name : Package Helm chart
143154 run : |
155+ mkdir -p ./charts
144156 helm package helm/crossview --destination ./charts
145157 ls -la ./charts/
146158
159+ - name : Login to GHCR (Helm OCI)
160+ if : github.event.inputs.publish_oci == 'true'
161+ run : |
162+ echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io \
163+ -u "${{ github.actor }}" \
164+ --password-stdin
165+
166+ - name : Push Helm chart to GHCR (OCI)
167+ if : github.event.inputs.publish_oci == 'true'
168+ env :
169+ CHART_VERSION : ${{ needs.validate-version.outputs.version }}
170+ run : |
171+ OCI_REGISTRY="ghcr.io"
172+ OCI_REPO="${{ github.repository_owner }}/crossview-chart"
173+ CHART_FILE=$(ls ./charts/*.tgz | head -1)
174+ if [ ! -f "$CHART_FILE" ]; then
175+ echo "::error::Chart package not found under ./charts/"
176+ exit 1
177+ fi
178+ echo "Pushing Helm chart to oci://$OCI_REGISTRY/$OCI_REPO (version $CHART_VERSION)"
179+ helm push "$CHART_FILE" "oci://$OCI_REGISTRY/$OCI_REPO" || {
180+ echo "First push attempt failed, retrying..."
181+ sleep 5
182+ helm push "$CHART_FILE" "oci://$OCI_REGISTRY/$OCI_REPO"
183+ }
184+
147185 - name : Checkout gh-pages branch
186+ if : github.event.inputs.update_github_pages == 'true'
148187 uses : actions/checkout@v4
149188 with :
150189 ref : gh-pages
@@ -153,6 +192,7 @@ jobs:
153192 fetch-depth : 0
154193
155194 - name : Initialize gh-pages if empty
195+ if : github.event.inputs.update_github_pages == 'true'
156196 run : |
157197 if [ ! -f gh-pages/index.yaml ]; then
158198 echo "Initializing gh-pages branch"
@@ -168,23 +208,27 @@ jobs:
168208 fi
169209
170210 - name : Create charts directory if it doesn't exist
211+ if : github.event.inputs.update_github_pages == 'true'
171212 run : |
172213 mkdir -p gh-pages/charts
173214 mkdir -p gh-pages/images
174215
175216 - name : Copy new chart package and logo
217+ if : github.event.inputs.update_github_pages == 'true'
176218 run : |
177219 cp charts/*.tgz gh-pages/charts/
178220 cp public/images/crossview-logo.svg gh-pages/images/crossview-logo.svg
179221 cp public/images/helm-logo.svg gh-pages/images/helm-logo.svg
180222
181223 - name : Update Helm repository index
224+ if : github.event.inputs.update_github_pages == 'true'
182225 run : |
183226 cd gh-pages
184227 helm repo index . --url https://crossplane-contrib.github.io/crossview
185228 cat index.yaml
186229
187230 - name : Create index.html for GitHub Pages
231+ if : github.event.inputs.update_github_pages == 'true'
188232 run : |
189233 cd gh-pages
190234 cat > index.html << 'EOF'
@@ -358,6 +402,7 @@ jobs:
358402 EOF
359403
360404 - name : Create Artifact Hub repository metadata
405+ if : github.event.inputs.update_github_pages == 'true'
361406 run : |
362407 cd gh-pages
363408 cat > artifacthub-repo.yml << 'EOF'
@@ -367,6 +412,7 @@ jobs:
367412 cat artifacthub-repo.yml
368413
369414 - name : Clean up gh-pages branch
415+ if : github.event.inputs.update_github_pages == 'true'
370416 run : |
371417 cd gh-pages
372418 find . -type f ! -name 'index.yaml' ! -name 'index.html' ! -name 'artifacthub-repo.yml' ! -name '*.tgz' ! -name 'README.md' ! -name '*.svg' ! -path './charts/*' ! -path './images/*' ! -path './.git/*' -delete 2>/dev/null || true
@@ -375,6 +421,7 @@ jobs:
375421 mkdir -p charts images
376422
377423 - name : Commit and push to gh-pages
424+ if : github.event.inputs.update_github_pages == 'true'
378425 run : |
379426 cd gh-pages
380427 git config user.name "github-actions[bot]"
0 commit comments