Trim comments to the non-obvious why
Test and deploy / test (push) Successful in 28s
Test and deploy / deploy (push) Successful in 31s

Drop narration, history and restated-code comments across the repo,
keep short ones for security boundaries, upstream quirks and ordering
constraints, and record the convention in CLAUDE.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-11-24 20:49:03 +00:00
co-authored by Claude Opus 5.5
parent effddd2794
commit 4530cb8dc4
222 changed files with 1173 additions and 5423 deletions
+5 -51
View File
@@ -1,55 +1,9 @@
#!/usr/bin/env bash
# =============================================================================
# gitea-runner/run.sh — register (once) and then run the Gitea Actions runner.
#
# WHAT IT DOES
# 1. Downloads the act_runner binary if it is not already present.
# 2. Blocks until Gitea answers on http://git.adam-french.co.uk:3000.
# 3. Registers with Gitea the first time only.
# 4. execs the runner daemon in the foreground.
#
# WHEN IT RUNS
# On the Pi, outside docker, as a long-lived process (systemd unit or nohup).
# It must be started from THIS directory: the script uses relative paths
# (./act_runner, .runner) and `act_runner daemon` looks for .runner in the
# current working directory.
#
# WHY IT WAITS FOR PORT 3000
# On a Pi reboot this process and the docker stack race. Registering or
# starting the daemon against a Gitea that is not up yet fails permanently
# rather than retrying, so the loop polls (forever, by design — there is no
# sensible timeout when the answer is "wait longer") until Gitea responds.
# It targets git.adam-french.co.uk:3000, Gitea's plain-HTTP port on its own
# LXC, which stpvm's /etc/hosts pins to the LXC's LAN IP — NOT the public
# https://git.adam-french.co.uk through Cloudflare — so the runner keeps
# working while the tunnel or the internet link is down. (It was
# localhost:3000, the forwarder's port, until 2026-11-24. An existing
# .runner keeps the address it registered with: edit its "address" field to
# move it, as was done then.)
#
# THE REGISTRATION TOKEN (one-shot, and easy to get wrong)
# GITEA_RUNNER_REGISTRATION_TOKEN comes from ./.env and is generated in the
# Gitea web UI (Site Administration -> Actions -> Runners -> Create new
# runner). It is a single-use enrolment token, NOT a lasting credential:
# registration exchanges it for a permanent runner identity written to the
# .runner file (gitignored — that file IS the real credential).
#
# The `if [ ! -f .runner ]` guard is what makes this idempotent. Once .runner
# exists the token is never used again and may safely be stale in .env. To
# re-register a runner you must delete .runner AND mint a FRESH token in the
# UI — reusing the old one will fail.
#
# --labels self-hosted must match `runs-on: self-hosted` in
# .gitea/workflows/*.yaml, or jobs queue forever with no runner picking them up.
#
# ENV VARS
# GITEA_RUNNER_REGISTRATION_TOKEN required for first registration only
# GITEA_RUNNER_NAME optional, defaults to "pi-runner"
# (this script does not source .env itself — export them or use an
# EnvironmentFile in the systemd unit)
#
# Diagnostics go to stderr so stdout stays clean for the daemon's own output.
# =============================================================================
# Registers (once) and runs the act_runner. Run from this directory.
# Waits for Gitea because registering against a down Gitea fails for good.
# GITEA_RUNNER_REGISTRATION_TOKEN is single-use: .runner is the real
# credential, so to re-register delete .runner and mint a fresh token.
# --labels must match `runs-on:` in .gitea/workflows/.
if [ ! -f ./act_runner ]; then
echo "act_runner binary not found. Downloading..." >&2
bash "$(dirname "$0")/download.sh"