4 Guides ci
Forgejo Actions edited this page 2026-11-22 02:20:14 +00:00

Generated CI (yawn.json)

Every repository declares its CI and CD in one file, yawn.json, at the root. yawn ci generate writes the Forgejo workflows from it; the generated files are committed (Forgejo only runs committed workflows) and must not be edited by hand.

Why this shape

  • One definition of every check. A job that runs a task executes yawn run <task>, the same command you run locally. A green check means the same thing on a laptop and on a runner.
  • No shared-workflow repository at run time. Each repository's workflows are complete, local files. Only the generator (this module) is shared.
  • No infrastructure secrets in CI. Signing and deploying are yawn request calls to xyOps, which verifies the caller (repository by ID, workflow, commit on main, required checks, digest) before doing anything.
  • Drift is a failed check. yawn ci verify regenerates and fails if a committed generated file differs. Run it as a task in CI.

Workflows that do not fit this shape stay hand-written next to the generated ones. verify only owns files that start with the generated marker.

The file

{
  "version": 1,
  "yawn": {"version": "0.3.0-dev.21", "sha256": {"linux_amd64": "…", "linux_arm64": "…"}},
  "defaults": {"runner": "ci-linux", "timeout": 20},
  "tasks": {
    "test": {"description": "Unit tests", "run": ["python3 -m unittest discover -s tests"]},
    "verify-generated": {"run": ["yawn ci verify"]}
  },
  "workflows": [
    {"file": "ci.yml", "name": "CI",
     "on": {"pull_request": {"branches": ["main"]}, "push": {"branches": ["main"]}},
     "jobs": [
       {"id": "test", "task": "test", "steps": [{"yawn": "run verify-generated"}]},
       {"id": "release-check", "uses": "release-check"}
     ]}
  ]
}
  • yawn pins the release the workflows install, with per-platform SHA-256. yawn ci pin VERSION prints the block. john/cdk itself uses "version": "source" plus build commands, so its CI tests the yawn it is about to release.
  • tasks: each task's commands run in order as one bash -euo pipefail script in dir (default the root), after the tasks in needs. yawn run TASK runs it with its dependencies; -only skips them; -n prints the scripts. Keep tasks thin wrappers over the real tools.
  • workflows: one generated file each. name prefixes every check name (CI / test (pull_request)), so changing it changes the required checks.

Jobs

Kind Keys Writes
task task, optional setup (before yawn) and steps (after) checkout, install pinned yawn, yawn run TASK
built-in uses: release-check, release, security, wiki; with a call to the john/release reusable workflow pinned at ci.ReleaseRef
steps steps checkout plus the steps; yawn steps get the pinned yawn installed

Common job keys: needs, if (a bare expression), runner (verbatim runs-on; default ${{ vars.CI_GENERAL_RUNNER || '<defaults.runner>' }}), image (none runs on the host), timeout, env, outputs, matrix, checkout (skip, fetch_depth, ref).

Jobs in a workflow with a pull_request trigger get the same-repository guard automatically, so fork pull requests never run on the home runners.

A step is exactly one of run, yawn (arguments to the pinned yawn) or uses, which names either action:NAME (pinned third-party actions: checkout, setup-node, setup-python, upload-artifact, download-artifact) or release:NAME (john/release actions at ci.ReleaseRef). Raw owner/repo@ref references are refused, so every action in a generated workflow is pinned by commit in one place.

Commit subjects (opt-in)

Add this step to an existing required PR job in yawn.json and set that job's "checkout": {"fetch_depth": 0}. Then run yawn ci generate.

{
  "name": "Lint PR commit subjects",
  "if": "github.event_name == 'pull_request'",
  "yawn": "ci lint-commits"
}

The command reads the PR base and head SHAs from the Forgejo event payload and checks the first line of every commit in base..head, not old base history or the temporary merge checkout. For example, fix(registry): reject a mismatched digest passes. Type and scope are required and lowercase; the whole subject may be at most 100 characters (including the prefix). Bodies and trailers are not checked. This does not change merge policy or lint a merge commit created later by Forgejo.

Run the same check locally with yawn ci lint-commits -base origin/main -head HEAD. Both commits and their history must be available locally; missing or shallow history fails the check instead of silently skipping commits.

Privileged requests

Enable "oidc": true and use the pinned release:submit-release action. Supply the registered repository ID, logical entry, trigger secret, and artifact digest if required. xyOps verifies OIDC and the registered release policy. CI waits for the matching terminal result of the submitted job, not for downstream deployment or approval. yawn digest FILE prints a file's sha256: digest (for example, provider SHA256SUMS).

Changing CI

  1. Edit yawn.json.
  2. yawn ci generate, then commit both.
  3. CI runs yawn ci verify; a stale or hand-edited workflow fails it.

Upgrading yawn: yawn ci pin NEW, paste the block, generate, commit. Bumping john/release or a pinned action is a cdk change (ci.ReleaseRef, ci/builtins.go) followed by regenerating each repository.