-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser-data.example.yml
More file actions
103 lines (83 loc) · 3.03 KB
/
Copy pathuser-data.example.yml
File metadata and controls
103 lines (83 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#cloud-config
---
# Example cloud-init for Raspberry Pi Imager.
# Write your real values into /etc/runner/config.env.
write_files:
- path: /etc/runner/config.env
permissions: "0644"
content: |
# Core config (required)
# Pin to a tag/commit for deterministic builds.
RUNNER_BOOTSTRAP_REPO_URL=https://github.com/your-org/github-runner.git
RUNNER_BOOTSTRAP_REPO_REF=main
# Optional: where to clone to
# APPLIANCE_CHECKOUT_DIR=/opt/runner
# Optional: install extra packages
# APPLIANCE_APT_PACKAGES="ca-certificates curl git"
# Runner installation location
# RUNNER_ACTIONS_RUNNER_DIR=/opt/runner/actions-runner
# systemd-nspawn base rootfs
# RUNNER_NSPAWN_BASE_ROOTFS=/var/lib/runner/nspawn/base-rootfs
- path: /usr/local/lib/runner/bootstrap.sh
permissions: "0755"
content: |
#!/usr/bin/env bash
set -euo pipefail
log() { echo "runner bootstrap: $*" >&2; }
die() { log "$*"; exit 1; }
require_cmd() { command -v "$1" >/dev/null 2>&1 || die "Missing required command: $1"; }
network_ok() { getent hosts github.com >/dev/null 2>&1 && curl -fsS https://github.com >/dev/null 2>&1; }
main() {
if [[ -f /var/lib/runner/installed ]]; then
log "Marker present; nothing to do."
exit 0
fi
require_cmd curl
require_cmd git
if ! network_ok; then
die "Network not ready yet"
fi
local repo_url="${RUNNER_BOOTSTRAP_REPO_URL:-https://github.com/theaussiepom/github-runner.git}"
local repo_ref="${RUNNER_BOOTSTRAP_REPO_REF:-main}"
local checkout_dir="${APPLIANCE_CHECKOUT_DIR:-/opt/runner}"
if [[ ! -d "$checkout_dir/.git" ]]; then
log "Cloning $repo_url -> $checkout_dir"
rm -rf "$checkout_dir"
git clone --no-checkout "$repo_url" "$checkout_dir"
fi
log "Fetching ref $repo_ref"
git -C "$checkout_dir" fetch --depth 1 origin "$repo_ref"
git -C "$checkout_dir" checkout -f FETCH_HEAD
if [[ ! -x "$checkout_dir/scripts/install.sh" ]]; then
die "Installer not found or not executable: $checkout_dir/scripts/install.sh"
fi
exec "$checkout_dir/scripts/install.sh"
}
main "$@"
- path: /etc/systemd/system/runner-install.service
permissions: "0644"
content: |
[Unit]
Description=runner first-boot installer
Wants=network-online.target
After=network-online.target
ConditionPathExists=!/var/lib/runner/installed
[Service]
Type=oneshot
EnvironmentFile=-/etc/runner/config.env
ExecStart=/usr/local/lib/runner/bootstrap.sh
Restart=on-failure
RestartSec=30
StartLimitIntervalSec=0
[Install]
WantedBy=multi-user.target
runcmd:
- - bash
- -lc
- apt-get update && apt-get install -y --no-install-recommends ca-certificates curl git
- - bash
- -lc
- systemctl daemon-reload
- - bash
- -lc
- systemctl enable --now runner-install.service