From 46e0d4f573abf3b5eb3de374a4582fefc9acbc55 Mon Sep 17 00:00:00 2001 From: sfriedrich Date: Thu, 8 Jan 2026 11:34:56 +0100 Subject: [PATCH] feat: add forgejo runner --- ct/forgejo-runner.sh | 95 ++++++++++++++++++++ install/forgejo-runner-install.sh | 140 ++++++++++++++++++++++++++++++ 2 files changed, 235 insertions(+) create mode 100644 ct/forgejo-runner.sh create mode 100644 install/forgejo-runner-install.sh diff --git a/ct/forgejo-runner.sh b/ct/forgejo-runner.sh new file mode 100644 index 000000000..c8196a4ea --- /dev/null +++ b/ct/forgejo-runner.sh @@ -0,0 +1,95 @@ +#!/usr/bin/env bash +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) + +# Copyright (c) 2026 +# Author: Simon Friedrich +# License: MIT +# Source: https://forgejo.org/ + +APP="Forgejo Runner" +var_tags="${var_tags:-ci}" +var_cpu="${var_cpu:-2}" +var_ram="${var_ram:-2048}" +var_disk="${var_disk:-8}" +var_os="${var_os:-debian}" +var_version="${var_version:-12}" + +# REQUIRED for Podman-in-LXC +var_unprivileged="1" +var_nesting="1" +var_keyctl="1" + +# ------------------------------------------------- +# Framework setup +# ------------------------------------------------- +header_info "$APP" +variables +color +catch_errors + +# ------------------------------------------------- +# Description +# ------------------------------------------------- +function description() { + cat </dev/null 2>&1; then + gpg --keyserver hkps://keys.openpgp.org --recv "$GPG_KEY" >/dev/null 2>&1 +fi + +gpg --verify /tmp/forgejo-runner.asc /usr/local/bin/forgejo-runner >/dev/null 2>&1 \ + && msg_ok "Signature valid" \ + || { msg_error "Signature verification failed"; exit 1; } + +# ------------------------------------------------- +# Runner registration +# ------------------------------------------------- +msg_info "Registering Forgejo Runner" + +export DOCKER_HOST="unix:///run/podman/podman.sock" + +forgejo-runner register \ + --instance "$FORGEJO_INSTANCE" \ + --token "$FORGEJO_RUNNER_TOKEN" \ + --name "$HOSTNAME" \ + --labels "linux-${ARCH}:docker://node:20-bookworm" \ + --no-interactive + +msg_ok "Runner registered" + +# ------------------------------------------------- +# systemd service +# ------------------------------------------------- +msg_info "Creating systemd service" + +cat </etc/systemd/system/forgejo-runner.service +[Unit] +Description=Forgejo Runner +Documentation=https://forgejo.org/docs/latest/admin/actions/ +After=podman.socket +Requires=podman.socket + +[Service] +User=root +WorkingDirectory=/root +Environment=DOCKER_HOST=unix:///run/podman/podman.sock +ExecStart=/usr/local/bin/forgejo-runner daemon +Restart=on-failure +RestartSec=10 +TimeoutSec=0 + +[Install] +WantedBy=multi-user.target +EOF + +systemctl daemon-reload +systemctl enable --now forgejo-runner +msg_ok "Forgejo Runner service enabled" + +motd_ssh +customize +cleanup_lxc \ No newline at end of file