fix(forgejo): accept FORGEJO_ADMIN_TOKEN and document PAT setup
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 3s

Align prune auth with railiance-apps forgejo tools and explain that
package prune needs a Forgejo PAT, not the OpenBao backup lane.
This commit is contained in:
tegwick 2026-07-12 11:57:35 +02:00
parent 715631dedd
commit 618641c984
2 changed files with 39 additions and 11 deletions

View file

@ -283,16 +283,23 @@ def build_delete_plans(
def load_token() -> str:
token = os.environ.get("FORGEJO_TOKEN", "").strip()
if token:
return token
token_file = os.environ.get("FORGEJO_TOKEN_FILE", "/tmp/forgejo-tegwick-api-token")
for env_name in ("FORGEJO_TOKEN", "FORGEJO_ADMIN_TOKEN"):
token = os.environ.get(env_name, "").strip()
if token:
return token
token_file = os.environ.get(
"FORGEJO_TOKEN_FILE",
os.environ.get("FORGEJO_ADMIN_TOKEN_FILE", "/tmp/forgejo-tegwick-api-token"),
)
path = Path(token_file).expanduser()
if path.is_file():
return path.read_text(encoding="utf-8").strip()
raise SystemExit(
"ERROR: set FORGEJO_TOKEN or FORGEJO_TOKEN_FILE "
"(Forgejo PAT with read:package and write:package)"
"ERROR: Forgejo API token required (read:package + write:package).\n"
" export FORGEJO_TOKEN=<pat> # or FORGEJO_ADMIN_TOKEN\n"
" # or save PAT to /tmp/forgejo-tegwick-api-token (chmod 600)\n"
" Generate: https://forgejo.coulomb.social/user/settings/applications\n"
" See: railiance-platform/docs/forgejo-package-prune.md"
)