Skip to content

Commit 6d9d446

Browse files
authored
Merge pull request #1645 from WaffleThief123/forgejo-runner-fix
forgejo-runner (FIX): support generated/unattended mode and configurable runner labels
2 parents 0d04c56 + 72b1a64 commit 6d9d446

2 files changed

Lines changed: 47 additions & 17 deletions

File tree

ct/forgejo-runner.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ var_unprivileged="${var_unprivileged:-1}"
1818
var_nesting="${var_nesting:-1}"
1919
var_keyctl="${var_keyctl:-1}"
2020

21+
# App-specific variables (not in build.func whitelist)
22+
# Export so they survive lxc-attach into the container
23+
export var_forgejo_instance="${var_forgejo_instance:-}"
24+
export var_forgejo_runner_token="${var_forgejo_runner_token:-}"
25+
export var_runner_labels="${var_runner_labels:-}"
26+
2127
header_info "$APP"
2228
variables
2329
color
@@ -56,6 +62,20 @@ function update_script() {
5662
exit
5763
}
5864

65+
# Fail early if running unattended without required values
66+
# mode is only set when the user explicitly passes it (automating);
67+
# bare "bash -c $(curl ...)" leaves mode empty and shows the whiptail menu
68+
if [[ -n "${mode:-}" ]]; then
69+
if [[ -z "${var_forgejo_instance:-}" ]]; then
70+
msg_error "var_forgejo_instance is required for unattended installs."
71+
exit 1
72+
fi
73+
if [[ -z "${var_forgejo_runner_token:-}" ]]; then
74+
msg_error "var_forgejo_runner_token is required for unattended installs."
75+
exit 1
76+
fi
77+
fi
78+
5979
start
6080
build_container
6181
description

install/forgejo-runner-install.sh

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,31 @@ setting_up_container
1212
network_check
1313
update_os
1414

15-
# Get required configuration with sensible fallbacks for unattended mode
16-
# These will show a warning if defaults are used
17-
var_forgejo_instance=$(prompt_input_required \
18-
"Forgejo Instance URL:" \
19-
"${var_forgejo_instance:-https://codeberg.org}" \
20-
120 \
21-
"var_forgejo_instance")
15+
# Get required configuration — skip prompts if already set (generated/unattended mode)
16+
if [[ -z "${var_forgejo_instance:-}" ]]; then
17+
read -r -p "${TAB3}Forgejo Instance URL (e.g. https://codeberg.org): " var_forgejo_instance
18+
var_forgejo_instance="${var_forgejo_instance:-https://codeberg.org}"
19+
fi
2220

23-
var_forgejo_runner_token=$(prompt_input_required \
24-
"Forgejo Runner Registration Token:" \
25-
"${var_forgejo_runner_token:-REPLACE_WITH_YOUR_TOKEN}" \
26-
120 \
27-
"var_forgejo_runner_token")
21+
if [[ -z "${var_forgejo_runner_token:-}" ]]; then
22+
read -r -p "${TAB3}Forgejo Runner Registration Token: " var_forgejo_runner_token
23+
fi
24+
25+
if [[ -z "${var_forgejo_runner_token:-}" ]]; then
26+
msg_error "No runner registration token provided. Cannot continue."
27+
exit 1
28+
fi
29+
30+
# Runner labels — default is always included; additional labels are appended
31+
DEFAULT_RUNNER_LABELS="linux-amd64:docker://node:22-bookworm"
32+
if [[ -z "${var_runner_labels:-}" ]]; then
33+
read -r -p "${TAB3}Additional runner labels (comma-separated, or leave blank for default only): " var_runner_labels
34+
fi
35+
if [[ -n "${var_runner_labels:-}" ]]; then
36+
RUNNER_LABELS="${DEFAULT_RUNNER_LABELS},${var_runner_labels}"
37+
else
38+
RUNNER_LABELS="${DEFAULT_RUNNER_LABELS}"
39+
fi
2840

2941
export FORGEJO_INSTANCE="$var_forgejo_instance"
3042
export FORGEJO_RUNNER_TOKEN="$var_forgejo_runner_token"
@@ -48,11 +60,12 @@ msg_ok "Installed Forgejo Runner"
4860

4961
msg_info "Registering Forgejo Runner"
5062
export DOCKER_HOST="unix:///run/podman/podman.sock"
63+
cd /root
5164
forgejo-runner register \
5265
--instance "$FORGEJO_INSTANCE" \
5366
--token "$FORGEJO_RUNNER_TOKEN" \
54-
--name "$HOSTNAME" \
55-
--labels "linux-amd64:docker://node:20-bookworm" \
67+
--name "$(hostname)" \
68+
--labels "$RUNNER_LABELS" \
5669
--no-interactive
5770
msg_ok "Registered Forgejo Runner"
5871

@@ -79,9 +92,6 @@ EOF
7992
systemctl enable -q --now forgejo-runner
8093
msg_ok "Created Services"
8194

82-
# Show warning if any required values used fallbacks
83-
show_missing_values_warning
84-
8595
motd_ssh
8696
customize
8797
cleanup_lxc

0 commit comments

Comments
 (0)