Helm Chart CI
Lint, template, kubeconform, commit lint, semantic release and publish for a Helm chart repo.
Publishes to the chart project's own
Helm package registry
with CI_JOB_TOKEN; no registry credentials.
Usage
.gitlab-ci.yml in the chart repo:
include:
- project: c2-games/infrastructure/gitlab-ci
ref: <tag>
file: /helm/helm-chart.yml
variables:
CHART_DIR: charts
Pin ref to a release tag that contains helm/helm-chart.yml.
v1.0.0 and v1.0.1 predate it; list tags with git ls-remote --tags. Never main.
Variables
| Key | Default | Description |
|---|---|---|
| CHART_DIR | charts | Chart directory (. if Chart.yaml is at root) |
| VALUES_DIR | ci | Extra values files *.yaml, each linted + rendered |
| HELM_CHANNEL | stable | Package registry channel |
| HELM_DEFAULT_VALUES | true | false: skip default values; lint/render only VALUES_DIR |
| HELM_IMAGE | alpine/helm:3.22.0 | Helm image |
| HELM_KUBECONFORM | true | false: skip the kubeconform job |
| KUBECONFORM_IMAGE | ghcr.io/yannh/kubeconform:v0.8.0-alpine | kubeconform image (needs a shell and apk) |
| KUBECONFORM_CRD_SCHEMAS | datreeio CRDs catalog URL template | Extra -schema-location, after default |
Charts with required values and no defaults set HELM_DEFAULT_VALUES: "false"
in their .gitlab-ci.yml and supply every required value in VALUES_DIR/*.yaml
(at least one file, else nothing is checked).
kubeconform runs -strict -ignore-missing-schemas on the helm_template output,
so it checks exactly the renders above. It fails on any invalid resource or error.
Kinds with no schema in the catalog (for example in-house CRDs) are not failures:
the job prints each skipped kind with its count and keeps kubeconform.json 1 week.
Baseline pin
The template includes /baseline.yml from this project at a release tag, not main,
so a consumer's tag fixes the whole pipeline. When cutting a release that changes
baseline.yml, bump ref in helm/helm-chart.yml to the previous tag in a commit
before tagging (a tag cannot name itself), then use the new tag in consumers.
Jobs
| Job | Stage | Runs on | Does |
|---|---|---|---|
| helm_lint | test | MR, default | helm lint --strict, default values (opt-out) + VALUES_DIR/*.yaml |
| helm_template | test | MR, default | helm template, fails on empty output, keeps rendered/ 1 week |
| kubeconform | test | MR, default | kubeconform on rendered/, k8s + CRDs catalog schemas |
| commit_lint | test | MR | Every commit subject is a Conventional Commit |
| semantic_release | publish | default branch | Shared: cuts vX.Y.Z tag + release |
| helm_publish | publish | default, v* |
Packages at the release version, POSTs to the registry, skips if exists |
The chart version in Chart.yaml is ignored: the git tag sets the published version.
No .releaserc in the chart repo; the job writes it.
Setup per chart repo
- Project Settings > CI/CD > Job token permissions: allow Git push requests to the repository.
semantic_releasecannot push the tag without it. - Optional: protect
v*tags.
Install a published chart:
Fixture
helm/fixture is the chart this repo's own pipeline lints and templates.
helm/fixture/chart-required has required values with no defaults and runs with
HELM_DEFAULT_VALUES: "false", proving the opt-out.
Release and publish jobs are disabled here; they are proven by the first chart repo pipeline.