Skip to content

Commit d2d4c28

Browse files
authored
ci: update GitHub Actions workflow to streamline Helm chart publishing to gh-pages (#218)
This pull request updates the GitHub Actions workflow for publishing Helm chart packages, simplifying the deployment process and improving how the Helm repo index is managed. The workflow now directly publishes artifacts to the `gh-pages` branch, removing the previous multi-step deployment to GitHub Pages and associated permissions. **Workflow and deployment simplification:** * Removed unnecessary `pages: write` and `id-token: write` permissions from the workflow, reflecting the new deployment approach. * Replaced the "Build Helm repo index for Pages" step with "Build Helm repo index for gh-pages", adding logic to fetch and merge the existing index from the `gh-pages` branch if present. This ensures the Helm repo index is correctly updated and avoids overwriting previous entries. **Direct publishing to `gh-pages`:** * Replaced the upload and deploy steps for GitHub Pages with a single step using `peaceiris/actions-gh-pages@v4` to publish the Helm repo directly to the `gh-pages` branch, simplifying the workflow and eliminating the need for a separate deploy job.
1 parent 9054d0c commit d2d4c28

1 file changed

Lines changed: 17 additions & 22 deletions

File tree

.github/workflows/publish-chart-packages.yml

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ permissions:
1717
contents: write
1818
pull-requests: read
1919
packages: write
20-
pages: write
21-
id-token: write
2220

2321
env:
2422
OCI_REGISTRY: ghcr.io
@@ -101,33 +99,30 @@ jobs:
10199
helm show chart "$PKG" | grep -E "^version: "
102100
helm push "$PKG" oci://$OCI_REGISTRY/${{ github.repository_owner }}/charts
103101
104-
- name: Build Helm repo index for Pages
102+
- name: Build Helm repo index for gh-pages
105103
env:
106104
CHART_VERSION: ${{ steps.meta.outputs.chart_version }}
107105
run: |
108106
set -euo pipefail
109107
PKG=$(ls dist/*.tgz)
110108
REPO="${GITHUB_REPOSITORY#*/}"
111109
BASE_URL="https://${GITHUB_REPOSITORY_OWNER}.github.io/${REPO}"
112-
helm repo index dist --url "$BASE_URL"
110+
if git ls-remote --exit-code origin gh-pages >/dev/null 2>&1; then
111+
git fetch origin gh-pages:gh-pages
112+
if git show gh-pages:index.yaml > dist/index.yaml 2>/dev/null; then
113+
helm repo index dist --url "$BASE_URL" --merge dist/index.yaml
114+
else
115+
helm repo index dist --url "$BASE_URL"
116+
fi
117+
else
118+
helm repo index dist --url "$BASE_URL"
119+
fi
113120
echo "Index generated for $BASE_URL"
114121
115-
- name: Upload Pages artifact
116-
uses: actions/upload-pages-artifact@v3
122+
- name: Publish Helm repo to gh-pages
123+
uses: peaceiris/actions-gh-pages@v4
117124
with:
118-
path: dist
119-
120-
deploy-pages:
121-
needs: publish
122-
runs-on: ubuntu-latest
123-
if: ${{ needs.publish.result == 'success' }}
124-
permissions:
125-
pages: write
126-
id-token: write
127-
environment:
128-
name: github-pages
129-
url: ${{ steps.deployment.outputs.page_url }}
130-
steps:
131-
- name: Deploy to GitHub Pages
132-
id: deployment
133-
uses: actions/deploy-pages@v4
125+
github_token: ${{ secrets.GITHUB_TOKEN }}
126+
publish_branch: gh-pages
127+
publish_dir: dist
128+
keep_files: true

0 commit comments

Comments
 (0)