Merge pull request #1645 from WaffleThief123/forgejo-runner-fix

forgejo-runner (FIX): support generated/unattended mode and configurable runner labels
This commit is contained in:
CanbiZ (MickLesk)
2026-04-30 15:39:37 +02:00
committed by GitHub
2 changed files with 47 additions and 17 deletions

View File

@@ -18,6 +18,12 @@ var_unprivileged="${var_unprivileged:-1}"
var_nesting="${var_nesting:-1}"
var_keyctl="${var_keyctl:-1}"
# App-specific variables (not in build.func whitelist)
# Export so they survive lxc-attach into the container
export var_forgejo_instance="${var_forgejo_instance:-}"
export var_forgejo_runner_token="${var_forgejo_runner_token:-}"
export var_runner_labels="${var_runner_labels:-}"
header_info "$APP"
variables
color
@@ -56,6 +62,20 @@ function update_script() {
exit
}
# Fail early if running unattended without required values
# mode is only set when the user explicitly passes it (automating);
# bare "bash -c $(curl ...)" leaves mode empty and shows the whiptail menu
if [[ -n "${mode:-}" ]]; then
if [[ -z "${var_forgejo_instance:-}" ]]; then
msg_error "var_forgejo_instance is required for unattended installs."
exit 1
fi
if [[ -z "${var_forgejo_runner_token:-}" ]]; then
msg_error "var_forgejo_runner_token is required for unattended installs."
exit 1
fi
fi
start
build_container
description

View File

@@ -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
forgejo-runner register \
--instance "$FORGEJO_INSTANCE" \
--token "$FORGEJO_RUNNER_TOKEN" \
--name "$HOSTNAME" \
--labels "linux-amd64:docker://node:20-bookworm" \
--name "$(hostname)" \
--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
motd_ssh
customize
cleanup_lxc