- Shell 100%
| .forgejo/workflows | ||
| scripts | ||
| .gitattributes | ||
| charts.yaml | ||
| README.md | ||
| renovate.json | ||
helm-fetcher
Mirror Helm charts from upstream registries into the private package registry of this Forgejo instance.
The repository contains a Forgejo Actions workflow and a small shell script that reads a chart inventory (charts.yaml), pulls each chart from its upstream registry, and publishes it to Forgejo. Charts that are already present are skipped, so the job is safe to run on a schedule.
Each chart is also rendered with helm template and the container images it
references are copied into the same registry with crane, so a mirrored chart
can be installed without pulling images from the public internet. See
Container images.
Layout
| Path | Purpose |
|---|---|
| charts.yaml | Chart inventory and target registry configuration |
| scripts/sync-charts.sh | Pull/push logic (bash, needs helm, yq, curl, crane) |
| .forgejo/workflows/sync-charts.yml | Entry workflow: manual, nightly schedule, push to main |
| .forgejo/workflows/reusable-sync-charts.yml | Reusable worker that installs the tools and runs the script |
Setup
- Create a token with
write:packagescope (Settings → Applications) and store it as a repository secret namedREGISTRY_TOKEN. - Optionally store the registry user as a repository secret named
REGISTRY_USER. When it is unset the repository owner is used. - If any chart needs upstream credentials, add the secrets referenced by that
chart's
authblock (for exampleUPSTREAM_USERNAME/UPSTREAM_PASSWORD). - Edit charts.yaml and push to
main, or run the workflow manually from the Actions tab.
The job runs on the runner label selected by the label matrix in
reusable-sync-charts.yml
(currently vm) inside the node:20-bookworm container image, so the runner
must be able to pull that image and reach get.helm.sh, github.com, and the
upstream chart registries.
helm, yq and crane are downloaded into .tools/bin in the workspace and
that directory is prepended to PATH for the sync step, so a helm/yq/crane
that happens to be preinstalled on the runner can never shadow the pinned
versions. The script refuses to run with a yq that is not the mikefarah Go
build or is older than v4.18.
Mirroring images needs write:package on the same token, and the runner must be
able to reach the upstream image registries (docker.io, ghcr.io, quay.io,
…). Set images.enabled: false in charts.yaml if the runner has
no such access.
Configuration reference
target:
mode: helm # helm | oci
registry: code.digitaledienst.overheid.nl
owner: dictu
oci_path: charts # optional, only for mode: oci
insecure: false # optional, skip TLS verification
plain_http: false # optional, plain HTTP instead of HTTPS
images:
enabled: true # optional, mirror the images the charts reference
naming: no_registry # optional, full | no_registry | chart_prefix | flat
platform: linux/amd64 # optional, mirror a single platform only
insecure: false # optional, skip TLS verification of upstream registries
plain_http: false # optional, plain HTTP for upstream registries
charts:
- name: ingress-nginx
type: http
source: https://kubernetes.github.io/ingress-nginx
chart: ingress-nginx
version: 4.11.3
target
| Key | Default | Description |
|---|---|---|
mode |
helm |
helm publishes to /api/packages/{owner}/helm/api/charts; oci uses helm push oci://{registry}/{owner}[/{oci_path}]. |
registry |
FORGEJO_SERVER_URL host |
Registry host, without scheme. |
owner |
repository owner | Package owner inside Forgejo. |
oci_path |
– | Extra path segment for OCI references. |
insecure |
false |
Pass --insecure-skip-tls-verify / curl -k. |
plain_http |
false |
Pass --plain-http to helm. |
images
| Key | Default | Description |
|---|---|---|
enabled |
true |
Mirror the container images the charts reference. |
naming |
no_registry |
Target path scheme, see Container images. |
platform |
– | Mirror only this platform (for example linux/amd64). Omit to copy the full multi-arch index. |
insecure |
false |
Skip TLS verification of upstream image registries. |
plain_http |
false |
Use plain HTTP for upstream image registries. |
charts[]
| Key | Required | Description |
|---|---|---|
name |
yes | Logical name; also the chart name when chart is omitted. Used by the only input. |
enabled |
no | false keeps the entry but skips it. |
type |
no | oci, http, or url. Inferred from source when omitted (oci:// → oci, *.tgz → url, otherwise http). |
source |
yes | oci://registry/path, a chart repository URL, or a direct .tgz URL. |
chart |
no | Chart name inside the repository. Defaults to name. |
version |
no | Exact version to mirror. Omit to mirror the newest release. |
versions |
no | List of exact versions to mirror. |
insecure |
no | Skip TLS verification for this upstream. |
plain_http |
no | Use plain HTTP for this upstream (OCI only). |
auth |
no | Upstream credentials, see below. |
images |
no | Per-chart image overrides, see Container images. |
Upstream credentials are read from environment variables so secrets never live in the inventory:
auth:
username_env: UPSTREAM_USERNAME
password_env: UPSTREAM_PASSWORD
Literal auth.username / auth.password values are also accepted, but prefer
the *_env form.
Workflow inputs
sync-charts.yml can be started manually with:
| Input | Description |
|---|---|
only |
Sync a single chart by name. Empty means all charts. |
dry_run |
Pull charts but do not push them. |
force |
Push even when the version already exists. |
images |
Also mirror the container images the charts reference (default true). |
The reusable workflow additionally accepts images_enabled. Forgejo's
workflow_call only supports inputs and outputs, so secrets are not
declared in the reusable workflow — the caller passes them with
secrets: inherit (or an explicit mapping) and the workflow reads
REGISTRY_TOKEN (required), REGISTRY_USER, UPSTREAM_USERNAME, and
UPSTREAM_PASSWORD (optional) from the secrets context. Call it from another
workflow with:
jobs:
sync:
uses: ./.forgejo/workflows/reusable-sync-charts.yml
with:
only: ingress-nginx
secrets: inherit
Running locally
The script only needs helm, curl, crane, and the mikefarah Go build of
yq:
export PACKAGES_TOKEN=<token>
export PACKAGES_USERNAME=<user>
export FORGEJO_SERVER_URL=https://code.digitaledienst.overheid.nl
bash scripts/sync-charts.sh
PACKAGES_TOKEN / PACKAGES_USERNAME are the script's own variable names; the
workflow maps the REGISTRY_TOKEN / REGISTRY_USER secrets onto them.
Useful overrides: CONFIG_PATH, ONLY, DRY_RUN=true, FORCE=true,
TARGET_MODE, TARGET_REGISTRY, TARGET_OWNER, TARGET_OCI_PATH,
TARGET_INSECURE, TARGET_PLAIN_HTTP, TARGET_URL, TARGET_USERNAME,
TARGET_PASSWORD, IMAGES_ENABLED. Everything else about image mirroring is
read from the images block in charts.yaml.
Behaviour notes
- A chart whose exact version already exists in the target registry is skipped
unless
forceis set. Formode: helmthis is checked against/api/packages/{owner}/helm/index.yaml; formode: ociagainsthelm show chart. - A failed chart does not stop the run; the job fails at the end and the step summary lists every chart with its result.
helm registry loginhas no--plain-httpflag, soplain_httponly affectshelm pull/helm push/helm show chart.helmkeeps a single credential store, so a per-chart upstream login would overwrite the target credentials. Inmode: ocithe script therefore logs in to the target registry again before each existence check and push.
Container images
When images.enabled is true (the default) every chart is rendered with
helm template <name> <chart.tgz> --namespace default --skip-tests
and each string-valued image: field in the output is copied into the target
registry with crane copy. crane talks to the registries directly, so no
Docker daemon is needed and the digest of the upstream image is preserved.
The target reference is {registry}/{owner}/{path}:{tag} where path depends on
images.naming. For an upstream image
docker.io/maykinmedia/openzaak:1.2.3 and owner dictu:
naming |
Target reference |
|---|---|
full |
dictu/docker.io/maykinmedia/openzaak:1.2.3 |
no_registry |
dictu/maykinmedia/openzaak:1.2.3 |
chart_prefix |
dictu/openzaak/maykinmedia/openzaak:1.2.3 |
flat |
dictu/openzaak:1.2.3 |
no_registry is the default: it keeps the upstream namespace so different
projects cannot collide, and it matches the layout Forgejo shows in its package
list. chart_prefix and flat group images by chart, which is convenient when
several charts ship the same upstream image at different tags.
Forgejo links a package to a repository when the image name starts with
{owner}/{repository}. None of the schemes above do that by default, so the
images show up under the owner's packages rather than in a repository's
Packages tab. Forgejo also treats tags case-insensitively, so two upstream tags
that differ only in case would collide.
Docker Hub shorthand is expanded before the path is built, so nginx becomes
docker.io/library/nginx:latest and nginx:1.25 becomes
docker.io/library/nginx:1.25. Images pinned by digest (app@sha256:…) keep the
digest, so the target reference is also digest-pinned.
Per-chart overrides
charts:
- name: openzaak
source: https://maykinmedia.github.io/charts/
images:
enabled: false # skip images for this chart
list: # explicit list instead of rendering the chart
- docker.io/openzaak/open-zaak:1.31.1
- docker.io/redis:8.0
auth: # credentials for private upstream images
username_env: UPSTREAM_USERNAME
password_env: UPSTREAM_PASSWORD
images.list accepts a sequence or a single string and replaces discovery
entirely. Use it for charts that build the image reference from separate values
keys (image.repository + image.tag), for charts whose templates only render
under specific values, or to pin an image the chart would otherwise resolve to a
floating tag. images.auth falls back to the chart-level auth block.
Behaviour
-
Images are mirrored before the chart existence check, so a chart that is already in the registry still gets its images copied on the next run.
-
craneonly has a global--insecureflag, soimages.insecure,images.plain_http,target.insecure, andtarget.plain_httpall apply to both the upstream and the target registry. -
crane auth loginstores credentials per host, so upstream and target logins coexist.images.authis only used for the upstream registry. -
A failed image does not stop the run; the job fails at the end and the step summary lists every image with its result.
-
Discovery only sees
image:fields that render as a single string. Charts that split repository and tag needimages.list. -
These cases fail the run with an explicit message instead of being skipped silently:
- an image reference that is not valid (bad tag, bad digest, uppercase or otherwise invalid repository path);
- a chart that cannot be rendered, or renders no manifests, so no images can be discovered;
images.listthat is neither a string nor a list of strings, or that is present but empty.
The render failures mean the chart ships images that discovery cannot see, so set
images.listfor it. -
A chart that renders but contains no
image:field at all only produces a warning, because it may legitimately ship no images. Setimages.enabled: falsefor such a chart to silence it.