-
-
Notifications
You must be signed in to change notification settings - Fork 284
forgejo-runner (FIX): support generated/unattended mode and configurable runner labels #1645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2145fac
cb9782d
034a196
e949ed7
fb95fe9
82ea3f2
237c0b7
17b2229
72b1a64
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,19 +12,31 @@ setting_up_container | |
| network_check | ||
| update_os | ||
|
|
||
| # Get required configuration with sensible fallbacks for unattended mode | ||
| # These will show a warning if defaults are used | ||
| var_forgejo_instance=$(prompt_input_required \ | ||
| "Forgejo Instance URL:" \ | ||
| "${var_forgejo_instance:-https://codeberg.org}" \ | ||
| 120 \ | ||
| "var_forgejo_instance") | ||
| # Get required configuration — skip prompts if already set (generated/unattended mode) | ||
| if [[ -z "${var_forgejo_instance:-}" ]]; then | ||
| read -r -p "${TAB3}Forgejo Instance URL (e.g. https://codeberg.org): " var_forgejo_instance | ||
| var_forgejo_instance="${var_forgejo_instance:-https://codeberg.org}" | ||
| fi | ||
|
|
||
| var_forgejo_runner_token=$(prompt_input_required \ | ||
| "Forgejo Runner Registration Token:" \ | ||
| "${var_forgejo_runner_token:-REPLACE_WITH_YOUR_TOKEN}" \ | ||
| 120 \ | ||
| "var_forgejo_runner_token") | ||
| if [[ -z "${var_forgejo_runner_token:-}" ]]; then | ||
| read -r -p "${TAB3}Forgejo Runner Registration Token: " var_forgejo_runner_token | ||
| fi | ||
|
|
||
| if [[ -z "${var_forgejo_runner_token:-}" ]]; then | ||
| msg_error "No runner registration token provided. Cannot continue." | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Runner labels — default is always included; additional labels are appended | ||
| DEFAULT_RUNNER_LABELS="linux-amd64:docker://node:22-bookworm" | ||
| if [[ -z "${var_runner_labels:-}" ]]; then | ||
| read -r -p "${TAB3}Additional runner labels (comma-separated, or leave blank for default only): " var_runner_labels | ||
| fi | ||
| if [[ -n "${var_runner_labels:-}" ]]; then | ||
| RUNNER_LABELS="${DEFAULT_RUNNER_LABELS},${var_runner_labels}" | ||
| else | ||
| RUNNER_LABELS="${DEFAULT_RUNNER_LABELS}" | ||
| fi | ||
|
|
||
| export FORGEJO_INSTANCE="$var_forgejo_instance" | ||
| export FORGEJO_RUNNER_TOKEN="$var_forgejo_runner_token" | ||
|
|
@@ -48,11 +60,12 @@ msg_ok "Installed Forgejo Runner" | |
|
|
||
| msg_info "Registering Forgejo Runner" | ||
| export DOCKER_HOST="unix:///run/podman/podman.sock" | ||
| cd /root | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is this needed now?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| forgejo-runner register \ | ||
| --instance "$FORGEJO_INSTANCE" \ | ||
| --token "$FORGEJO_RUNNER_TOKEN" \ | ||
| --name "$HOSTNAME" \ | ||
| --labels "linux-amd64:docker://node:20-bookworm" \ | ||
| --name "$(hostname)" \ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think hostname var is set by our core funcs, why does this need changing?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is set by core funcs, and that's the problem. HOSTNAME="${TAB}🏠${TAB}${CL}"It's clobbering the bash builtin |
||
| --labels "$RUNNER_LABELS" \ | ||
| --no-interactive | ||
| msg_ok "Registered Forgejo Runner" | ||
|
|
||
|
|
@@ -79,9 +92,6 @@ EOF | |
| systemctl enable -q --now forgejo-runner | ||
| msg_ok "Created Services" | ||
|
|
||
| # Show warning if any required values used fallbacks | ||
| show_missing_values_warning | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That call only fired the warning if |
||
|
|
||
| motd_ssh | ||
| customize | ||
| cleanup_lxc | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't you do something like this?
var_keyctl="${var_keyctl:-1}"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That pattern works for
var_forgejo_instancesince it has a sensible default (https://codeberg.org), and that's already howct/forgejo-runner.shdeclares it at the top of the file. But it doesn't work for the other two:var_forgejo_runner_tokenhas no sensible default. Every install needs a unique secret from the user's Forgejo instance. The previous code usedREPLACE_WITH_YOUR_TOKENas a fallback, but that just delays failure: the runner registration call rejects it and the install dies mid-way with a confusing auth error.var_runner_labelsis opt-in extra labels appended to a default. Using${var_runner_labels:-}silently would skip the interactive prompt entirely for users running the script the normal way (bash -c "$(curl …ct/forgejo-runner.sh)").The
read -r -pblock is what gives the interactive UX. Happy to swap to a helper if there's a preferred one.prompt_input_requiredwas the original choice, but it returns a fallback string on timeout or non-TTY rather than failing, which is what landed us with the brokenREPLACE_WITH_YOUR_TOKENbehavior.