From 7981ca2022365d004b9452d00ad5219307e0bf85 Mon Sep 17 00:00:00 2001 From: Mikkeli Date: Wed, 26 Aug 2026 23:53:04 +0900 Subject: [PATCH] fix(ci): register from the runner's own directory with an absolute state path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Registration failed with `open .runner: permission denied`. runner.file was the relative `.runner`, which resolves against the caller's working directory — the repo the admin ran sudo from, which the service account cannot write. The same applied to .runner.lock, so the single-process guard was skipped too. Two fixes rather than one, because either alone leaves a trap: runner.file is now absolute, and register runs with cwd set to the runner's home. An earlier draft did cd there; that was lost when the script was rewritten for a system service, and an absolute path is what makes it not matter next time. Also drops --labels from the register call, which gitea-runner ignores and warns about whenever the config file defines labels, and rewrites a config that exists while nothing is registered yet — such a config is provisional, not in use, and leaving a broken one in place was what required manual cleanup here. Co-Authored-By: Claude Opus 5 --- tool/setup_ci_runner.sh | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/tool/setup_ci_runner.sh b/tool/setup_ci_runner.sh index 0d629ec..8ba3abb 100755 --- a/tool/setup_ci_runner.sh +++ b/tool/setup_ci_runner.sh @@ -168,15 +168,22 @@ fi # ── Config ───────────────────────────────────────────────────────────────── say "Config" CONFIG="$RUNNER_HOME/config.yaml" -if [[ -f "$CONFIG" ]]; then - echo " $CONFIG exists, leaving it alone" +if [[ -f "$CONFIG" && -f "$RUNNER_HOME/.runner" ]]; then + # Registered: this config is in use, do not touch it. + echo " $CONFIG exists and the runner is registered — leaving it alone" else + if [[ -f "$CONFIG" ]]; then + echo " $CONFIG exists but nothing is registered yet — rewriting it" + fi cat > "$CONFIG" <&2