#!/usr/bin/env bash # Example: set up a Werkator instance that watches and builds Werkator itself. # Run from inside a working checkout of the Werkator repository. # # Usage: # GIT_ACCOUNT=mi GIT_TOKEN=xxxx ./docs/examples/setup-werkator-selfhost.sh # (both empty is fine for a public origin — commit statuses just won't be published) set -euo pipefail INSTALL_DIR="${INSTALL_DIR:-$HOME/werkator-selfhost}" GIT_ACCOUNT="${GIT_ACCOUNT:-}" # technical Gitea user for HTTPS fetch + status API GIT_TOKEN="${GIT_TOKEN:-}" # Gitea API token — stays in the uncommitted config file SERVER_PORT="${SERVER_PORT:-18080}" DEV_CHECKOUT=$(git rev-parse --show-toplevel) ORIGIN_URL="${ORIGIN_URL:-$(git -C "$DEV_CHECKOUT" remote get-url origin)}" # 1. Build the Werkator jar — the last Gradle run you ever start by hand. (cd "$DEV_CHECKOUT" && ./gradlew --console=plain build) # 2. Dedicated clone: builds run in worktrees under its .git/werkator/worktrees, # completely separate from your dev checkout. mkdir -p "$INSTALL_DIR" cp "$DEV_CHECKOUT/build/libs/werkator.jar" "$INSTALL_DIR/werkator.jar" if [ ! -d "$INSTALL_DIR/repo/.git" ]; then git clone "$ORIGIN_URL" "$INSTALL_DIR/repo" fi cd "$INSTALL_DIR/repo" # 3. Generate the config templates; existing files are kept. The clone already # carries the committed .werkator.yml, so this only creates the machine config # (.git/werkator/.werkator.yml). java -jar "$INSTALL_DIR/werkator.jar" init # 4. Machine-specific overrides and secrets (.git/werkator/ is never committed; # this file deep-merges over .werkator.yml and wins). cat > .git/werkator/.werkator.yml <