Shared composite actions for Forgejo Actions on git.metawave.ch
  • JavaScript 85.6%
  • Shell 14.4%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
grok 70d68f0852
All checks were successful
Validate / validate (push) Successful in 19s
Workflow-Vorlagen für Consumer-Repos (Concurrency, Timeouts, gepinntes checkout)
2026-12-06 13:33:03 +01:00
.forgejo/workflows Workflow-Vorlagen für Consumer-Repos (Concurrency, Timeouts, gepinntes checkout) 2026-12-06 13:33:03 +01:00
code/scan mise/setup und trivy/cache auslagern, Gradle-Cache-Key, Action-Refs mit SHA (#33) 2026-12-06 11:58:51 +01:00
go mise/setup und trivy/cache auslagern, Gradle-Cache-Key, Action-Refs mit SHA (#33) 2026-12-06 11:58:51 +01:00
image Härten: Upload-Token, image/build-Heredoc, bundler-audit, Chrome-Cache (#32) 2026-12-06 12:00:25 +01:00
jvm mise/setup und trivy/cache auslagern, Gradle-Cache-Key, Action-Refs mit SHA (#33) 2026-12-06 11:58:51 +01:00
lib validate workflow: yamllint (own yaml/lint), shellcheck of every run block and lib/log.sh, node --check; drop the dead pull_request trigger mapping 2026-11-19 03:31:21 +01:00
mise/setup mise/setup und trivy/cache auslagern, Gradle-Cache-Key, Action-Refs mit SHA (#33) 2026-12-06 11:58:51 +01:00
node/setup mise/setup und trivy/cache auslagern, Gradle-Cache-Key, Action-Refs mit SHA (#33) 2026-12-06 11:58:51 +01:00
python/lint validate: Schema-Check, trivy-summary-Tests und Lint-Smoke-Tests (#29) 2026-12-06 11:42:48 +01:00
rails Härten: Upload-Token, image/build-Heredoc, bundler-audit, Chrome-Cache (#32) 2026-12-06 12:00:25 +01:00
test canary: nächtlicher Lauf der Actions gegen Fixtures (#31) 2026-12-06 12:01:02 +01:00
trivista/upload Härten: Upload-Token, image/build-Heredoc, bundler-audit, Chrome-Cache (#32) 2026-12-06 12:00:25 +01:00
trivy/cache mise/setup und trivy/cache auslagern, Gradle-Cache-Key, Action-Refs mit SHA (#33) 2026-12-06 11:58:51 +01:00
workflow-templates Workflow-Vorlagen für Consumer-Repos (Concurrency, Timeouts, gepinntes checkout) 2026-12-06 13:33:03 +01:00
yaml/lint validate: Schema-Check, trivy-summary-Tests und Lint-Smoke-Tests (#29) 2026-12-06 11:42:48 +01:00
.editorconfig feat: composite actions for Trivy, Trivista upload and Docker publish 2026-11-16 23:18:25 +01:00
.yamllint.yaml validate workflow: yamllint (own yaml/lint), shellcheck of every run block and lib/log.sh, node --check; drop the dead pull_request trigger mapping 2026-11-19 03:31:21 +01:00
README.md Workflow-Vorlagen für Consumer-Repos (Concurrency, Timeouts, gepinntes checkout) 2026-12-06 13:33:03 +01:00
renovate.json mise/setup und trivy/cache auslagern, Gradle-Cache-Key, Action-Refs mit SHA (#33) 2026-12-06 11:58:51 +01:00

ci/actions

Shared composite actions for Forgejo Actions on git.metawave.ch. Each action is the harmonized best variant of what the former Woodpecker pipelines did per repository. Public because Forgejo runners only fetch actions from public repositories; contains no secrets, callers pass them as inputs.

Building blocks

Action Purpose Job image
image/build Build via docker/build-push-action (per-job builder, nothing left on the runner) with registry layer cache; on the default branch push main-<unix-ts>-<sha8> + latest (or explicit tags), then image/scan with SBOM; elsewhere dry run. Optional platforms (cross-compile; no QEMU set up) and Docker Hub mirror ubuntu-latest (docker CLI)
image/scan Trivy image scan → log summary → Trivista; optional CycloneDX SBOM as run artifact sbom-<name>-<tag> (expires with the artifact retention) any
code/scan Trivy filesystem scan (offline) → log summary → Trivista → fail on CRITICAL any, after checkout
trivy/cache Restore the daily Trivy vulnerability + Java DB cache into .trivy-cache. Used by code/scan and image/scan any
trivista/upload Upload a Trivy JSON report, log the scan link any
jvm/setup JDK from mise.toml via mise (GitHub releases, no Adoptium API) + Maven/Gradle cache (Gradle key also hashes gradle.properties, libs.versions.toml and gradle-wrapper.properties) any
jvm/qodana Checkout + Qodana Community for JVM with cached Maven/Gradle dependencies (the cache is saved even when the analysis fails); the report (qodana.sarif.json + HTML report/) is attached to the run as artifact qodana-report (also when the analysis fails; input retention-days, default 14). The HTML report needs an HTTP server (python3 -m http.server in report/), index.html does not work from file:// any
node/setup Node.js from mise.toml via mise + npm cache (keyed on package-lock.json) any
rails/setup Ruby from .ruby-version/.tool-versions/mise.toml (prebuilt) + cached bundle without production, libvips if needed; replaces per-repo CI images ubuntu-latest
rails/ci The app's bin/ci (Rails 8.1: steps in config/ci.rb, the same checks as locally); Google Chrome when it runs system tests (checksum from Google's apt index, cached by version and architecture), their failure screenshots as artifact ubuntu-latest
rails/audit Nightly dependency audit: bundler-audit, any advisory fails (bin/bundler-audit with config/bundler-audit.yml if present) + importmap audit ubuntu-latest
yaml/lint yamllint with the repository's .yamllint* config; optional path (default .) ubuntu-latest (pipx)
python/lint ruff check + ruff format --check (config from ruff.toml/pyproject.toml); optional path (default .) any, after checkout
go/setup Go from mise.toml via mise + module/build cache any
mise/setup Pinned mise release + tools from mise.toml (install_args). Used by jvm/setup, node/setup and go/setup any
go/lint golangci-lint (config from .golangci.yml, else defaults) any, after checkout
go/vulncheck go/setup + govulncheck; fails only on vulnerabilities the code reaches ubuntu-latest

Reference them with the full URL (short owner/repo refs resolve against data.forgejo.org):

- uses: https://git.metawave.ch/ci/actions/code/scan@main
  with:
    trivista-token: ${{ secrets.TRIVISTA_TOKEN }}

Expected org secrets: REGISTRY_USERNAME, REGISTRY_PASSWORD, TRIVISTA_TOKEN; for the Docker Hub mirror also DOCKERHUB_TOKEN plus the org variable DOCKERHUB_USERNAME (vars.): a secret's value is masked in every log, and a username equal to the org name would turn every path into ***. Repositories owned by a user (e.g. toubi) see no org secrets and only the owner can push to their packages: they use user-level secrets/variables of that user (REGISTRY_USERNAME = the user as variable, REGISTRY_PASSWORD = a write:package token of the user, TRIVISTA_TOKEN), set by a site admin via the API with the Sudo: <user> header.

Conventions

  • Layout: <area>/<action>/action.yml, shared shell/JS helpers in lib/.
  • Composite actions, not reusable workflows: inside reusable workflows Forgejo 17.0 / runner v13 still reports event_name as workflow_call (required so on.workflow_call.inputs work; see Forgejo #10614, since v15). That hides the original trigger (push, schedule, …) and breaks trigger detection in these actions (e.g. trivista/upload). Callers keep thin workflows (triggers + uses:).
  • Logging (lib/log.sh): every step logs what it does (==>; not ▶, which Forgejo draws in front of collapsible groups), the relevant parameters and why (e.g. why a push is skipped), the outcome (✔/✘, digests, finding counts, scan links). Verbose tool output goes into collapsible ::group:: blocks. Skips are never silent (↷ with the reason). Secrets are named, never printed.
  • Names: every workflow, step and matrix job gets a name:. Without one Forgejo shows the uses: ref (actions/checkout@<sha>) or the first command, a scheduled run is titled with the file path, and a matrix job lists every matrix value. Forgejo interpolates ${{ }} in job names, not in step names.
  • Triggers: push on every branch, no pull_request. Forgejo runs a pull request on its head commit, the same one the push already tested, so every Renovate update ran twice; the push run's commit status shows on the PR anyway.
  • Default branch comes from the event payload, so main and master repositories both work.
  • Pinning: third-party actions by short ref and commit SHA (owner/repo@<sha> # vX.Y.Z); the runner resolves them against data.forgejo.org. Images by digest. Renovate keeps them current (helpers:pinGitHubActionDigests, with forgejo-tags on data.forgejo.org so forgejo/upload-artifact is found too) and waits minimumReleaseAge: 3 days before proposing a release, except for vulnerability alerts. Tags are mutable — see the trivy-action tag hijack of 2026-03-19 (CVE-2026-33634). An action that is not mirrored on data.forgejo.org is silently skipped; those (jdx/mise-action, ruby/setup-ruby) use the full GitHub URL. Our own building blocks reference each other by @main. Tool versions outside uses: carry a # renovate: datasource=… depName=… comment on the line above.
  • Versioning: @main until all repositories are migrated, then v1 tags.
  • Validate (.forgejo/workflows/validate.yaml): forgejo-runner validate against the action, workflow and template schema (the templates are validated one by one, --directory does not look into workflow-templates/), yamllint, shellcheck of every run: block (actions, workflows and templates), a fixture test of lib/trivy-summary.js, and smoke tests of yaml/lint and python/lint against test/fixtures (a passing and a failing case each).

Pitfalls (learned the hard way)

  • Short action refs resolve against data.forgejo.org. An action that is not mirrored there is silently skipped (the job continues). Use the full URL (https://github.com/owner/action@sha) for anything else.
  • GITHUB_TOKEN is Forgejo's job token. Actions that send it to github.com (mise-action, setup-trivy) must get an empty token (github_token: '', GITHUB_TOKEN: '' in the step env).
  • mise-action exports mise.toml [env] by default, overriding the workflow's env with local development values (reeeder: DB_URL=localhost). The setup actions pass env: false; jvm/setup sets JAVA_HOME itself.
  • The runner image ships third-party apt repos (packages.microsoft.com, PPAs) that can stall apt-get update for minutes; install from the Ubuntu archive only and set DEBIAN_FRONTEND=noninteractive.
  • No shared tool caches between parallel jobs: setup-ruby reinstalls Bundler into its Ruby on every run. Prefer installers that do not need remote version APIs (mise for JDKs instead of the Adoptium API).
  • Forgejo's registry races on concurrent uploads of the same new blob (unique constraint on package_blob, then a nil-pointer panic → 500). buildx pushes image and cache in parallel, so image/build exports the cache in a second, sequential step.
  • Schedule events carry no repository: forgejo.event.repository.default_branch is empty, so a check like forgejo.ref == format('refs/heads/{0}', forgejo.event.repository.default_branch) is false on every scheduled run (Renovate ran dry for a day). Compare against the branch name instead (forgejo.ref == 'refs/heads/main'). /actions/runs does not list scheduled runs either; /actions/tasks does.
  • ${{ is evaluated anywhere in run:, even in a shell comment or a sed pattern; an unparsable one makes the whole workflow unusable ("YAML Schema validation error"). Write [$]{{ where the characters are meant literally.
  • Runner restarts kill running jobs (they show as running until Forgejo's zombie timeout); roll out runner config changes when no jobs run.

Workflow templates

workflow-templates/ holds the standard structure of a consumer workflow, one file per archetype. Copy the file that fits to .forgejo/workflows/ of the repository and adjust the TODO lines. (The folder is called workflow-templates so Renovate's github-actions manager finds the actions/checkout pin in it by default.)

Template Archetype Used by (today)
ci-image.yaml Dockerfile only: image/build caddy, healthchecks, homepage, typingmind, kube-build-tools, mdb (with python/lint), sandstrand, web
ci-jvm.yaml Maven/Gradle: jvm/qodana, jvm/setup, tests, image/build tickets, covid19, reeeder (backend), zeiterfassung-tools, trackz (backend, Jib instead of image/build)
ci-node.yaml Node.js frontend: node/setup, npm checks, image/build reeeder (frontend), trackz (frontend)
ci-go.yaml Go: go/lint, go/setup + tests, image/build http-logger-proxy
ci-rails.yaml Rails: rails/ci (bin/ci), image/build; without bin/ci: rails/setup + bundle exec rake meinfest, sarah-und-marcel, sharebox, tiradelza, covid-checkin, TaskPort, tidyup, forgejo-registry-cleanup
security.yaml nightly code/scan + image/scan every repository with an image
security-rails.yaml the same plus rails/audit the Rails repositories

What every template sets, and why:

  • concurrency with group ${{ forgejo.workflow }}-${{ forgejo.ref }} and cancel-in-progress: ${{ forgejo.ref != 'refs/heads/main' && forgejo.ref != 'refs/heads/master' }}: a newer push to a feature or Renovate branch cancels the older run of the same workflow, the default branch is never cancelled (an image push or a nightly scan runs to the end). Both default-branch names are listed because the expression must not depend on the event payload (default_branch is empty on scheduled runs). Workflows of the same repository do not cancel each other: the workflow name is part of the group.
  • timeout-minutes per job, so a hanging step does not block the runner for hours: 10 for lint, scans and audits (they take 1 to 3 minutes), 15 for the Node build, 20 for Qodana, Rails checks, JVM build and image builds (up to 8 minutes today, the first run without a cache takes longer). A job that really needs more raises its own value.
  • actions/checkout@<sha> # vX.Y.Z in the short form (see Pinning), our own actions as https://git.metawave.ch/ci/actions/…@main.
  • Triggers: push and workflow_dispatch; the security workflow adds the nightly schedule and limits push to the files that change a scan result.

Renovate in a consumer repository needs no configuration for the checkout pin: the github-actions manager reads .forgejo/workflows/*.yaml. A shared preset (pin digests, minimumReleaseAge) would only be worth it to carry the settings of this repository's renovate.json over to the consumers.

A Go repository adds the vulnerability check to its security workflow:

  vulncheck:
    runs-on: ubuntu-latest
    timeout-minutes: 10
    steps:
      - name: Checkout
        uses: actions/checkout@<sha> # vX.Y.Z
      - name: Check vulnerabilities (govulncheck)
        uses: https://git.metawave.ch/ci/actions/go/vulncheck@main

Migrating a repository from Woodpecker

  1. Enable Actions on the repository (has_actions); it was disabled on many repositories. Remove leftover repository secrets from the 2025 Actions setup (REGISTRY_*, DOCKERHUB_*, ...): repository secrets shadow the org secrets of the same name.
  2. Add .forgejo/workflows/ci.yaml (start from workflow-templates/; checks → build; Rails apps: rails/ci runs bin/ci, plain Ruby: bundle exec rake) and security.yaml (audit, code scan, nightly image scan) with enable-email-notifications: true; remove .woodpecker/, Dockerfile.ci and leftover .github/workflows (Forgejo runs those when .forgejo/workflows is missing).
  3. Test on a branch (builds are dry runs there), then merge to the default branch.
  4. Deactivate the repository in Woodpecker (woodpecker-cli repo rm <repo> deactivates, history is kept).
  5. Delete the packages Woodpecker left behind: the CI image <repo>-ci (built from Dockerfile.ci) and generic <repo>-sbom packages; the SBOM is now an artifact of the run.

Canary

.forgejo/workflows/canary.yaml runs every night at 02:00 UTC (03:00 Europe/Zurich in winter, 04:00 during daylight time) and can be started by hand (workflow_dispatch). It reuses the validate checks via workflow_call and additionally exercises node/setup, jvm/setup, go/setup and go/lint against test/fixtures, so a stale pin or a broken upstream tool shows up before a consumer build fails. code/scan is included only when TRIVISTA_TOKEN is present, because the action requires it for the Trivista upload. Scheduled workflows run from the default branch only. A failed or recovered scheduled run emails the contact address of the ci organization (set in the org settings).