Automate helm chart publishing using GitHub action
GitHub Pages is definitely a great platform to host your helm repository. Especially when you are hosting charts of an open source project. In this story we will look at how we can host the helm repository on GitHub Pages and automatically publish the chart to repository using GitHub action and Helm Chart Releaser.
Tools used:
1. GitHub Pages
2. Helm chart releaser
3. GitHub Action
Host helm repository on GitHub pages:
I referred to Mattia Peri’s story on how to create a public helm repo with GitHub pages initially and made few enhancements on the top of that.
i. Enable GH pages under repository settings
ii. Url to be used; Default: <username>.github.io/<repo>
iii. HTTPs can also be enforced on the page by checking the option as show in the image above
Steps to publish chart to helm repo hosted in github pages
- Create a github repo
- Keep helm chart under charts directory in the repo
- Create gh-pages branch
- Create github actions yaml under .github/workflows/release.yml
name: Release Charts
on:
push:
branches:
- master
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Install Helm
uses: azure/setup-helm@v1
with:
version: v3.4.0
- name: Run chart-releaser
uses: helm/chart-releaser-action@v1.1.0
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
Note: We don’t have to create GITHUB_TOKEN secret explicitly, it is an implicit environment that translates to user token.
Whenever any helm chart under charts directory needs to be published, along with the changes to the chart, chart version shall be bumped. It will be detected automatically by chart releaser action.
Chart releaser action will automatically create a tag and release the chart. It will also simultaneously update the index.yml file in gh-pages branch.
Automating helm chart publishing will avoid the pain of packaging chart and updating index.yml everytime a chart is added.
I hope this short article on hosting and publishing helm chart on github pages helped.
Stay tuned for more interesting articles. Cheers!