- **ADR 0010** (accepted): the build configuration stays expressible as a Forgejo Actions workflow. A new build-definition key needs a workflow counterpart; host-side keys are exempt. - **RFC 0006** (proposed): one workflow for Forgejo and Werkator, and the steps towards it. Step 1 is implemented here. - **`werkator export:forgejo`**, wrapped by **`tools/werkator-to-forgejo`**: converts the committed `.werkator.yml` (never the `.git` layers or `~/.werkator.yml`) into `.forgejo/workflows/werkator-<build>.yml`, one per definition that triggers on its own, follow-ups as jobs with `needs`. Untranslatable constructs become comments and stderr lines; `--strict` refuses. - `AGENTS.md`: the ADR 0010 rule as a hard invariant; column-aligned Markdown tables. - v1.28.0 On Werkator's own `.werkator.yml` the converter names two constructs: `builds.deploy` has no committed trigger (the host adds it), and `werkdock.env` is sandbox environment. PR-doc: `docs/prs/2026-10-03-PR#92-forgejo-actions-compatible-config.md` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: mhoennig <michael@hoennig.de> Reviewed-on: #92
43 lines
1.8 KiB
Bash
Executable File
43 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Converts a repository's committed .werkator.yml into Forgejo Actions workflows
|
|
# (RFC 0006, step 1), one workflow per build definition that triggers on its own,
|
|
# its follow-ups as jobs with `needs`. What has no workflow counterpart is
|
|
# written as a comment in the workflow and listed on stderr.
|
|
#
|
|
# Usage:
|
|
# tools/werkator-to-forgejo [REPO] [--stdout] [--strict] [--output-dir DIR] [--runs-on LABEL]
|
|
#
|
|
# REPO the target repository, or any directory inside it (default: .);
|
|
# the .werkator.yml in its root is converted, and the workflows are
|
|
# written into it, below .forgejo/workflows/
|
|
# --output-dir where to write them instead, relative to the repository root,
|
|
# e.g. .gitea/workflows for a Gitea forge
|
|
# --stdout print the workflows instead of writing them
|
|
# --strict write nothing and exit 1 when anything cannot be converted
|
|
# --runs-on the runner label of every job (default: docker)
|
|
#
|
|
# Only the committed file is read: the .git layers, the applied fragment and
|
|
# ~/.werkator.yml are runner and instance configuration in Forgejo terms, and
|
|
# they hold the secrets.
|
|
#
|
|
# The conversion is Werkator's `export:forgejo` command, so it binds the file
|
|
# exactly as Werkator does. It runs the `werkator` named by WERKATOR_BIN, else
|
|
# the one on PATH, else the jar of this checkout (built when missing).
|
|
set -euo pipefail
|
|
|
|
if [ -n "${WERKATOR_BIN:-}" ]; then
|
|
werkator=("$WERKATOR_BIN")
|
|
elif command -v werkator >/dev/null 2>&1; then
|
|
werkator=(werkator)
|
|
else
|
|
here="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
jar="$here/build/libs/werkator.jar"
|
|
if [ ! -f "$jar" ]; then
|
|
echo "==> Building $jar" >&2
|
|
(cd "$here" && ./gradlew -q bootJar) >&2
|
|
fi
|
|
werkator=(java -jar "$jar")
|
|
fi
|
|
|
|
exec "${werkator[@]}" export:forgejo "$@"
|