-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
github: separate workflow for helm repo index update
No need to (re-)build documentation when a release is published. Great simplification of the Helm repo index update script: do not scan all releases but just get the assets from the release that was published. This separation should make the maintenance of scripts and workflows easier.
- Loading branch information
Showing
4 changed files
with
78 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: gh-pages | ||
on: | ||
release: | ||
types: [published, edited] | ||
|
||
concurrency: | ||
group: gh-pages | ||
|
||
jobs: | ||
update-helm-repo: | ||
name: Update gh-pages helm repo index | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Install Helm | ||
uses: azure/setup-helm@v3 | ||
with: | ||
version: 3.12.3 | ||
|
||
- name: Check out repo | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Update repo index | ||
run: | | ||
git config user.name "Github Actions" | ||
git config user.email "no-reply@github.com" | ||
./scripts/github/update-helm-repo.sh ${{ join(github.event.release.assets.*.browser_download_url, ' ') }} | ||
- name: Push | ||
run: git push -f https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} gh-pages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/bin/bash -e | ||
set -o pipefail | ||
|
||
asset_urls="$@" | ||
|
||
git checkout gh-pages | ||
cd charts | ||
|
||
# Download chart(s) from release assets | ||
for asset_url in $asset_urls; do | ||
if ! echo "$asset_url" | grep -q 'chart.*tgz$'; then | ||
echo "Skipping $asset_url, does not look like a Helm chart archive" | ||
continue | ||
fi | ||
|
||
echo "Downloading $asset_url..." | ||
curl -sSfLO $asset_url | ||
# We rely on all release assets having the same baseurl | ||
download_baseurl=`dirname $asset_url` | ||
done | ||
|
||
if [ -z "$download_baseurl" ]; then | ||
echo "No Helm chart release assets found" | ||
exit 0 | ||
fi | ||
|
||
echo "Updating helm index" | ||
helm repo index . --merge index.yaml --url $download_baseurl | ||
|
||
# Check if there were any changes in the repo | ||
if [ -z "`git status --short`" ]; then | ||
echo "No changes in Helm repo incex, gh-pages branch already up-to-date" | ||
exit 0 | ||
fi | ||
|
||
# Create a new commit | ||
commit_msg="Update Helm repo index for release `basename $download_baseurl` | ||
Auto-generated by `basename $0`" | ||
|
||
echo "Committing changes..." | ||
git commit -m "$commit_msg" -- index.yaml | ||
|
||
echo "gh-pages branch successfully updated" |