Skip to content

Commit

Permalink
ci: Rebuild helm repo index on every push to main
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmidyson committed Feb 8, 2024
1 parent 2f8ffa9 commit 6b41819
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 49 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/github-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,37 @@ jobs:
run: |
wget -O "${{ runner.temp }}/hugo.deb" "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb" \
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
- name: Install Dart Sass
run: sudo snap install dart-sass

- name: Checkout
uses: actions/checkout@v4

- name: Setup Pages
id: pages
uses: actions/configure-pages@v4

- name: Install Node.js dependencies
run: if [[ -f package-lock.json || -f npm-shrinkwrap.json ]]; then npm ci; fi
working-directory: docs

- name: Update Helm index
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mapfile -t releases < <( devbox run -- gh release list --json tagName | devbox run -- gojq -r .[].tagName )
for release in "${releases[@]}"; do
if devbox run -- gh release download "${release}" \
--pattern 'capi-runtime-extensions-*.tgz' \
--dir docs/static/helm; then
devbox run -- helm repo index docs/static/helm \
--url "https://github.com/${{ github.repository }}/releases/download/${release}" \
--merge docs/static/helm/index.yaml
rm -f docs/static/helm/*.tgz
fi
done
- name: Build with Hugo
env:
# For maximum backward compatibility with Hugo modules
Expand All @@ -61,6 +82,7 @@ jobs:
--minify \
--baseURL "${{ steps.pages.outputs.base_url }}/"
working-directory: docs

- name: Upload artifact
if: github.ref == 'refs/heads/main'
uses: actions/upload-pages-artifact@v3
Expand Down
29 changes: 1 addition & 28 deletions .github/workflows/release-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,35 +64,8 @@ jobs:
--app-version ${{ github.ref_name }}
devbox run -- gh release upload ${{ github.ref_name }} capi-runtime-extensions-*.tgz
- uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0

- name: Install devbox
uses: jetpack-io/[email protected]
with:
enable-cache: true

- name: Update and commit Helm index
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FILE_TO_COMMIT: docs/static/helm/index.yaml
run: |
devbox run -- helm repo index . \
--url "https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}" \
--merge "${FILE_TO_COMMIT}"
mv index.yaml "${FILE_TO_COMMIT}"
MESSAGE="build(${{ github.ref_name }}): Update Helm index"
SHA=$( git rev-parse "main":"${FILE_TO_COMMIT}" )
devbox run -- gh api --verbose --method PUT "/repos/:owner/:repo/contents/${FILE_TO_COMMIT}" \
--field message="${MESSAGE}" \
--field content=@<( base64 -i "${FILE_TO_COMMIT}" ) \
--field encoding="base64" \
--field branch="main" \
--field sha="${SHA}"
- name: Build GitHub pages
uses: benc-uk/workflow-dispatch@v1
with:
workflow: github-pages.yml
ref: main
21 changes: 0 additions & 21 deletions docs/static/helm/index.yaml

This file was deleted.

0 comments on commit 6b41819

Please sign in to comment.