Reusable Forgejo Actions workflows: docker builder, helm builder
  • Go 74.7%
  • Dockerfile 25.3%
Find a file
Jonas Leder 3563f10060
Some checks failed
docker-build.yml / Merge pull request 'Revert Renovate PRs merged with failed pipelines' (#3) from revert-failed-renovate into master (push) Failing after 0s
go-binaries.yml / Merge pull request 'Revert Renovate PRs merged with failed pipelines' (#3) from revert-failed-renovate into master (push) Failing after 0s
helm-build.yml / Merge pull request 'Revert Renovate PRs merged with failed pipelines' (#3) from revert-failed-renovate into master (push) Failing after 0s
selftest / go (push) Blocked by required conditions
selftest / build-1 (push) Successful in 26s
selftest / helm (push) Successful in 0s
selftest / build (linux/amd64) (push) Successful in 54s
selftest / build (windows/arm64) (push) Successful in 50s
selftest / upload (push) Waiting to run
selftest / sbom (push) Successful in 1m24s
selftest / build (push) Successful in 1m58s
selftest / docker (push) Successful in 0s
Merge pull request 'Revert Renovate PRs merged with failed pipelines' (#3) from revert-failed-renovate into master
2026-11-18 23:07:12 +00:00
.forgejo/workflows Revert "Merge pull request 'Update https://code.forgejo.org/forgejo/upload-artifact action to v5' (#1) from renovate/https-code.forgejo.org-forgejo-upload-artifact-5.x into master" 2026-11-19 00:07:03 +01:00
tests go-binaries: reusable Go cross-compile workflow 2026-11-18 10:46:27 +01:00
README.md go-binaries: upload with curl SigV4 (mc download is gone), only own artifacts 2026-11-18 11:18:05 +01:00
renovate.json Add reusable docker and helm build workflows 2026-11-18 00:10:23 +01:00

ci-snippets

Reusable Forgejo Actions workflows for the infra organization. Other repositories include them with uses:, so a docker or helm build is a few lines.

The repository must stay public: Forgejo only resolves reusable workflows from public repositories.

Workflow Does
docker-build.yml multi-arch image build with rootless buildkit, push, trivy scan (image and repo)
go-binaries.yml Go cross-compile matrix (GOOS/GOARCH), artifacts, optional S3 upload (curl SigV4), update.json and SBOM
helm-build.yml helm lint, package and optional push (OCI or helm package registry)

Docker image

.forgejo/workflows/build.yml in your repository:

on:
  push:
    branches: ['**']
    tags: ['**']

jobs:
  docker:
    uses: infra/ci-snippets/.forgejo/workflows/docker-build.yml@master
    secrets: inherit

Pushes <registry>/<owner>/<repo>:<branch> and :<commit sha>, latest on the default branch.

Inputs (all optional): registry, image-name, image-suffix (appended to the default name, for several images per repo), context-dir (build subdirectory), pre-build (shell command before the build), image-tag, dockerfile-path (directory), architectures, push, additional-args, trivy-skip, trivy-timeout, registry-mirror, runs-on. Outputs: digest, image. Reports (trivy JSON, SBOM, image-hash.txt) are uploaded as artifact build-reports.

Example that keeps the image name from GitLab, builds one architecture and uses the digest:

jobs:
  docker:
    uses: infra/ci-snippets/.forgejo/workflows/docker-build.yml@master
    with:
      image-name: forgejo.jonasled.dev/infra/some-image
      architectures: amd64
    secrets: inherit
  deploy:
    needs: docker
    runs-on: default
    steps:
    - run: echo "${{ needs.docker.outputs.digest }}"

Helm chart

jobs:
  chart:
    uses: infra/ci-snippets/.forgejo/workflows/helm-build.yml@master
    with:
      chart-path: chart
      push: ${{ github.ref_type == 'tag' }}
    secrets: inherit
  • version: version input, else the tag without a leading v on tag builds, else Chart.yaml
  • registry-type: oci (default) pushes to oci://<host>/<owner>/<repo>/charts, so the old GitLab path jonasled.dev/<owner>/<repo>/charts stays the same; change it with oci-path
  • registry-type: classic pushes to https://<registry>/api/packages/<owner>/helm, consume it with helm repo add x https://<registry>/api/packages/<owner>/helm
  • version-from-run-number: true: version becomes <major.minor of Chart.yaml>.<run number>, so versions only grow (Flux picks the highest); version-offset is added to the run number, set it to the last pipeline number of the old GitLab project
  • pre-package (shell, before lint; REGISTRY is set), extra-checks (shell, after lint), post-package (shell, after packaging; CHART is the .tgz), lint-args (for example --strict)
  • other inputs: registry, app-version (default: commit SHA), lint, runs-on; output: chart-version

Go binaries

jobs:
  binaries:
    uses: infra/ci-snippets/.forgejo/workflows/go-binaries.yml@master
    with:
      binary-name: myapp
      # targets: '["linux/amd64","darwin/arm64"]'     # default: linux, windows, darwin x amd64, arm64
      # build-number-var: main.BuildNumber            # -X <var>=<run number + build-number-offset>
      # build-time-var: main.BuildTime
      # build-number-offset: '244'                    # last pipeline number of the old GitLab project
      # upload: true                                  # PUT to S3 on the default branch
      # update-json: true                             # also write and upload update.json
      # sbom-file: myapp.bom.xml                      # CycloneDX SBOM artifact
    secrets:
      S3_HOST: ${{ secrets.S3_HOST }}                 # only with upload
      S3_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }}
      S3_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }}
      S3_BUCKET: ${{ secrets.S3_BUCKET }}

Other inputs: module-dir (go.mod directory, default .), package (default ./), ldflags (default -s -w), cgo-enabled (default 0, empty leaves it unset), windows-exe, go-version, update-url, runs-on. Each target is an artifact <binary-name>-<goos>-<goarch> (7 days). Do not pass github.* values through with:, they arrive empty.

Requirements

  • Runner labels: buildkit for docker-build.yml and default for helm-build.yml (runs-on input to change). The buildkit label is defined in the flux repo (services/forgejo-runner): its pod spec runs the infra/docker-build image as non-root with seccomp and apparmor unconfined, not privileged. The builder image and its tag are set there, not in the workflows.
  • registry defaults to forgejo.jonasled.dev and is not derived from the server URL, because the runner reports its internal cluster URL (http://forgejo-http.forgejo.svc.cluster.local:3000). After the domain cutover change the default in both workflows once.
  • Forgejo with workflow_call support, and a runner version that supports it.
  • Push credentials: the automatic workflow token cannot push packages on this instance (401). The org infra has the secrets REGISTRY_USER (ci-bot) and REGISTRY_TOKEN (scope write:package, read:package). Other orgs and users need the same two secrets; secrets: inherit passes them on.

Known behaviour

Forgejo's container registry answers parallel uploads of a new package with HTTP 500 (duplicate package row). Both workflows retry the push, and the builder pushes each tag in its own build to avoid pushing the same blobs twice.

Tests

.forgejo/workflows/selftest.yml calls both workflows against tests/ without pushing. selftest-push.yml (manual) pushes a multi-arch test image and a test chart; delete the packages afterwards.