hetzner: validate GitHub runner token before provisioning any VM#19
Merged
igorpecovnik merged 1 commit intomainfrom Apr 24, 2026
Merged
hetzner: validate GitHub runner token before provisioning any VM#19igorpecovnik merged 1 commit intomainfrom
igorpecovnik merged 1 commit intomainfrom
Conversation
Previously, a stale / under-scoped GITHUB_TOKEN produced this
silent failure:
1. action reports success — Hetzner VM reaches STATUS_RUNNING
within ~30s
2. cloud-init runs for 5-10 min (apt update, Docker install,
armbian-config install, runner download)
3. armbian-config --api module_armbian_runners install POSTs
/orgs/<org>/actions/runners/registration-token — gets
401/403
4. the response body is piped into `jq -r .token` which
silently yields the string "null"
5. ./config.sh --token null --unattended fails with a cryptic
message buried in /var/log/cloud-init-output.log
6. zero runners ever come online, the VM gets billed for
PERIOD minutes doing nothing
Add a pre-flight check: GET /orgs/armbian/actions/runners
?per_page=1 with the supplied token. The same scope that can
call registration-token can also list runners, so this is a
cheap side-effect-free proxy. Fail loudly on 401/403/404/
network, naming the exact scope the token needs, before touching
Hetzner.
Organisation is hardcoded (armbian) to match the value baked
into get_cloud_init_config(); parameterise together in a future
pass if the action is ever reused for a different org.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stale / under-scoped
GITHUB_TOKENcurrently produces this silent failure on the Hetzner runner workflow:STATUS_RUNNINGwithin ~30s.cloud-initruns for 5–10 min (apt update, Docker install,armbian-configinstall, runner tarball download).module_armbian_runners installPOSTs/orgs/<org>/actions/runners/registration-token— gets 401/403.jq -r .tokenwhich silently yields the literal string"null"../config.sh --token null --unattendedfails with a cryptic message buried in/var/log/cloud-init-output.log.PERIODminutes doing nothing.(We hit exactly this in https://github.com/armbian/armbian.github.io/actions/runs/24497359721 — the cloud-init log showed
jq: error (at <stdin>:4): Cannot iterate over null (null)repeated 9× from the runner-list paging loop inmodule_armbian_runners, which is how the expired token surfaced.)Change
Add a pre-flight
GET /orgs/armbian/actions/runners?per_page=1with the supplied token, invoked frommain()right after the existing "token present" check and before thehcloud.Clientis even constructed. Exit non-zero on 401/403/404/network, naming the exact scope the token needs.Reason it's a safe proxy for the scope we actually need: the same permission that authorises
GET /orgs/<org>/actions/runnersalso authorisesPOST /orgs/<org>/actions/runners/registration-token, so a 200 here reliably implies runner registration will work. Listing is side-effect-free and cheap.Organisation is hardcoded to
armbianto match the value baked intoget_cloud_init_config()on themodule_armbian_runners install organisation=armbianline. If the action is ever reused for a different org, both should be parameterised together in a follow-up.Test plan
armbian.github.ioHetzner runner workflow with a valid token → validation passes silently, VM provisioning proceeds as before.validate_github_tokenwithHTTP 401 — Token is invalid or expired; no Hetzner VM is created.admin:org/ Self-hosted runners scope → action fails withHTTP 403 — Token authenticates but lacks permission to manage runners on 'armbian'.--action deletepath skips the check (no registration happens during teardown).