How to host your Helm chart repository on GitHub
Apr 2, 2020 · 8 minute readSince the release of Helm 3, the officialhelm/chartsrepository has been deprecated in favour ofHelm Hub. While it’s great for decentralization and the long term sustainability of the project, I think there’s a lot more that is lost. Where is the best place to go for of the expert advice now? Installing Helm now requires you to manually add each repository you use. And there’s now some added friction to hosting your Helm charts.
Thankfully GitHub has all the tools required, in the form ofGitHub PagesandGitHub Actions, to host a fully automated build pipeline and to host a repository for your Helm charts. Also, we can use some of the tools from the community to ensure our charts are high quality.
GitHub Pages
First you need to go ahead and create agh-pagesbranch in your repository. As I’m writing this there’san issueopen to do this automatically, but to do it manually you can run the following:
1git checkout --orphan gh-pages2git rm -rf .3git commit -m"Initial commit"--allow-empty4git pushOnce you’ve done that, you need to enable GitHub Pages in your repository. Go to the settings page on your repository and set the source branch to thegh-pagesbranch you just created.

Now you’ve configured GitHub Pages, it will act as your Helm repository. Next, you need to configure GitHub Actions to publish to there.
GitHub Actions
You’re going to use GitHub Actions to create two workflows: one for pull requests, and one for commits to master. Your pull request workflow will deal with linting and testing your chart using a collection of automated tooling. While this isn’t a direct replacement for the expert advice offered by the Helm community, it’s better than nothing. Your master branch workflow will deal with releasing your charts using GitHub pages, meaning you never have to do it manually.
First up let’s look at the pull request workflow.
Pull requests
For each pull request in your chart repository, you want to run a series of different validation and linting tools to catch any avoidable mistakes in your Helm charts. To do that, go ahead and create a workflow in your repository by creating a file at.github/workflows/ci.yamland add the following YAML to it:
1name:Lint and Test Charts23on:4pull_request:5paths:6-'charts/**'78jobs:This will run the workflow on any pull request that changes files under the charts directory.
That’s the skeleton of the workflow sorted, next onto the tools that you’re going to use.
Chart Testing
The Helm project created Chart Testing, AKAct, as a comprehensive linting tool for Helm charts. To use it in your pull request build, you’ll go ahead and add the following job:
1lint-chart:2runs-on:ubuntu-latest3steps:4-name:Checkout5uses:actions/checkout@v16-name:Run chart-testing (lint)7uses:helm/chart-testing-action@master8with:9command:lint10config:.github/ct.yamlWherect.yamlis:
1helm-extra-args:--timeout 6002check-version-increment:true3debug:trueFor a full list of configuration options check out thissample file.
Thelintaction for Chart Testing is a bit of a catch-all that helps you prevent a lot of potential bugs or mistakes in your charts. That includes:
- Version checking
- YAML schema validation on
Chart.yaml - YAML linting on
Chart.yamlandvalues.yaml - Maintainer validation on changed charts
Helm-docs
Helm-docs isn’t strictly a linting tool, but it makes sure that your documentation stays up-to-date with the current state of your chart. It requires that you create aREADME.md.gotmplin each chart repository using theavailable templates, otherwise it will create aREADME.mdfor you using a default template.
To use it as part of your pull request build, you need to add the following job:
1lint-docs:2runs-on:ubuntu-latest3needs:lint-chart4steps:5-name:Checkout6uses:actions/checkout@v17-name:Run helm-docs8run:.github/helm-docs.shWherehelm-docs.shis:
1#!/bin/bash2set-euo pipefail34HELM_DOCS_VERSION="0.11.0"56# install helm-docs7curl --silent --show-error --fail --location --output /tmp/helm-docs.tar.gz https://github.com/norwoodj/helm-docs/releases/download/v"${HELM_DOCS_VERSION}"/helm-docs_"${HELM_DOCS_VERSION}"_Linux_x86_64.tar.gz8tar -xf /tmp/helm-docs.tar.gz helm-docs910# validate docs11./helm-docs12git diff --exit-codeThis runs Helm-docs against each chart in your repository and generates theREADME.mdfor each one. Then, using git, you’ll fail the build if there are any differences. This ensures that you can’t check in any changes to your charts without also updating the documentation.
Kubeval
Next up is Kubeval. It validates the output from Helm against schemas generated from the Kubernetes OpenAPI specification. You’re going to add it to your pull request, and use it to validate across multiple different versions of Kubernetes. Add the following job:
1kubeval-chart:2runs-on:ubuntu-latest3needs:4- lint-chart5- lint-docs6strategy:7matrix:8k8s:9- v1.12.1010- v1.13.1211- v1.14.1012- v1.15.1113- v1.16.814- v1.17.415steps:16-name:Checkout17uses:actions/checkout@v118-name:Run kubeval19env:20KUBERNETES_VERSION:${{ matrix.k8s }}21run:.github/kubeval.shWherekubeval.shis:
1#!/bin/bash2set-euo pipefail34CHART_DIRS="$(git diff --find-renames --name-only"$(git rev-parse --abbrev-ref HEAD)"remotes/origin/master -- charts|grep'[cC]hart.yaml'|sed -e's#/[Cc]hart.yaml##g')"5KUBEVAL_VERSION="0.14.0"6SCHEMA_LOCATION="https://raw.githubusercontent.com/instrumenta/kubernetes-json-schema/master/"78# install kubeval9curl --silent --show-error --fail --location --output /tmp/kubeval.tar.gz https://github.com/instrumenta/kubeval/releases/download/"${KUBEVAL_VERSION}"/kubeval-linux-amd64.tar.gz10tar -xf /tmp/kubeval.tar.gz kubeval1112# validate charts13forCHART_DIR in${CHART_DIRS};do14helm template"${CHART_DIR}"|./kubeval --strict --ignore-missing-schemas --kubernetes-version"${KUBERNETES_VERSION#v}"--schema-location"${SCHEMA_LOCATION}"15doneThis script is a bit longer, but if you break it down step-by-step it’s essentially:
- Get a list of charts that have been changed between this PR and master branch
- Install Kubeval
- For each chart:
- Generate the Kubernetes configuration using Helm
- Validatate the configuration using Kubeval
You’re doing this for each version of Kubernetes you’ve defined in the job, so if you’re using an API that isn’t available in all versions, Kubeval will fail the build. This help keep backwards compatibility for all of your charts, and makes sure you’re not releasing breaking changes accidentally.
This doesn’t guarantee that the chart will actually install successfully on Kubernetes—but that’s where Kubernetes in Docker comes in.
Kubernetes in Docker (KIND)
Finally you’re going to use Chart Testing again to install your Helm charts on a Kubernetes cluster running in the GitHub Actions runner using Kubernetes in Docker (KIND). Like Kubeval, you can create clusters for different versions of Kubernetes.
KIND doesn’t publish Docker images for each version of Kubernetes, so you need to look at the Dockerimage tags. That’s why the Kubernetes versions in this job won’t necessarily match the versions used for the Kubeval job.
1install-chart:2name:install-chart3runs-on:ubuntu-latest4needs:5- lint-chart6- lint-docs7- kubeval-chart8strategy:9matrix:10k8s:11- v1.12.1012- v1.13.1213- v1.14.1014- v1.15.715- v1.16.416- v1.17.217steps:18-name:Checkout19uses:actions/checkout@v120-name:Create kind ${{ matrix.k8s }} cluster21uses:helm/kind-action@master22with:23node_image:kindest/node:${{ matrix.k8s }}24-name:Run chart-testing (install)25uses:helm/chart-testing-action@master26with:27command:install28config:.github/ct.yamlSo you got a temporary Kubernetes cluster, installed your charts on it, and ran anyhelm tests(that you definitely wrote 🙄). This is the ultimate test of your Helm chart—installing and running it. If this passes, and you merge your pull request, you’re ready to release!
Releasing
Remember thatgh-pagesbranch you created earlier? Now you can use it to publish your fully tested Helm chart to.
You’re going to create another GitHub workflow, this time at.github/workflows/release.yaml. This one is going to be significantly simpler:
1name:Release Charts23on:4push:5branches:6- master7paths:8-'charts/**'910jobs:11release:12runs-on:ubuntu-latest13steps:14-name:Checkout15uses:actions/checkout@v116-name:Configure Git17run:|18git config user.name "$GITHUB_ACTOR"19git config user.email "$GITHUB_ACTOR@users.noreply.github.com"20-name:Run chart-releaser21uses:helm/chart-releaser-action@master22env:23CR_TOKEN:'${{ secrets.CR_TOKEN }}'It will check out the repository, set the configuration of Git to the user that kicked-off the workflow, and run the chart releaser action. The chart releaser action will package the chart, create a release from it, and update theindex.yamlfile in thegh-pagesbranch. Simple!
But one thing you still need to do is create a secret in your repository,CR_TOKEN, which contains a GitHubpersonal access tokenwithreposcope. This is due to aGitHub Actions bug, where GitHub Pages is not deployed when pushing from GitHub Actions.

Once that’s all configured, any time a change under the charts directory is checked in, like from a pull request, your Github workflow will run and your charts will be available almost instantly!
Next steps
From here you’ll want to add your repository to Helm so you can use it, and share it onHelm Hubso others can too. For the former, you’ll need to run:
1helm repo add renovate https://<username>.github.io/<repository>/2helm repo updateAnd for the latter, the Helm project have writtena comprehensive guidethat I couldn’t possibly top.
If you want to see all these pieces working together checkout therenovatebot/helm-chartsrepository, or our page onHelm Hub. And if you would like some help please reach out to me on Bluesky at@jamiemagee.bsky.social.