diff --git a/ct/forgejo-runner.sh b/ct/forgejo-runner.sh new file mode 100644 index 000000000..59145398c --- /dev/null +++ b/ct/forgejo-runner.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func) + +# Copyright (c) 2021-2026 community-scripts ORG +# Author: Simon Friedrich +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# 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}" + +var_unprivileged="${var_unprivileged:-1}" +var_nesting="${var_nesting:-1}" +var_keyctl="${var_keyctl:-1}" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + + if [[ ! -f /usr/local/bin/forgejo-runner ]]; then + msg_error "No ${APP} installation found!" + exit 1 + fi + + msg_info "Stopping Services" + systemctl stop forgejo-runner + msg_ok "Stopped Services" + + RELEASE=$(curl -fsSL https://data.forgejo.org/api/v1/repos/forgejo/runner/releases/latest | grep -oP '"tag_name":\s*"\K[^"]+' | sed 's/^v//') + msg_info "Updating Forgejo Runner to v${RELEASE}" + curl -fsSL "https://data.forgejo.org/forgejo/runner/releases/download/v${RELEASE}/forgejo-runner-linux-amd64" -o forgejo-runner + chmod +x /usr/local/bin/forgejo-runner + msg_ok "Updated Forgejo Runner" + + msg_info "Starting Services" + systemctl start forgejo-runner + msg_ok "Started Services" + msg_ok "Updated successfully!" + exit +} + +start +build_container +description + +msg_ok "Completed successfully!\n" +echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" diff --git a/frontend/public/json/forgejo-runner.json b/frontend/public/json/forgejo-runner.json new file mode 100644 index 000000000..1ffd96d0b --- /dev/null +++ b/frontend/public/json/forgejo-runner.json @@ -0,0 +1,35 @@ +{ + "name": "Forgejo Runner", + "slug": "forgejo-runner", + "categories": [ + 20 + ], + "date_created": "2026-01-12", + "type": "ct", + "updateable": true, + "privileged": false, + "interface_port": null, + "documentation": "https://forgejo.org/docs/latest/admin/actions/runner-installation/", + "config_path": "/root/.runner", + "website": "https://forgejo.org/docs/latest/admin/actions/runner-installation/", + "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons@main/webp/forgejo.webp", + "description": "Forgejo Runner is a lightweight service that executes CI/CD jobs for Forgejo, enabling automated builds, tests, and deployments.", + "install_methods": [ + { + "type": "default", + "script": "ct/forgejo-runner.sh", + "resources": { + "cpu": 2, + "ram": 2048, + "hdd": 8, + "os": "Debian", + "version": "12" + } + } + ], + "default_credentials": { + "username": null, + "password": null + }, + "notes": [] +} \ No newline at end of file diff --git a/install/forgejo-runner-install.sh b/install/forgejo-runner-install.sh new file mode 100644 index 000000000..f6bea2f5f --- /dev/null +++ b/install/forgejo-runner-install.sh @@ -0,0 +1,83 @@ +#!/usr/bin/env bash +# Copyright (c) 2021-2026 community-scripts ORG +# Author: Simon Friedrich +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://forgejo.org/ + +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +if [[ -z "$var_forgejo_instance" ]]; then + read -rp "Forgejo Instance URL (e.g. https://code.forgejo.org): " var_forgejo_instance +fi + +if [[ -z "$var_forgejo_runner_token" ]]; then + read -rp "Forgejo Runner Registration Token: " var_forgejo_runner_token + echo +fi + +if [[ -z "$var_forgejo_instance" || -z "$var_forgejo_runner_token" ]]; then + echo "❌ Forgejo instance URL and runner token are required." + exit 1 +fi + +export FORGEJO_INSTANCE="$var_forgejo_instance" +export FORGEJO_RUNNER_TOKEN="$var_forgejo_runner_token" + +msg_info "Installing dependencies" +$STD apt install -y \ + git \ + podman podman-docker +msg_ok "Installed dependencies" + +msg_info "Enabling Podman socket" +systemctl enable --now podman.socket +msg_ok "Enabled Podman socket" + +msg_info "Installing Forgejo Runner" +RUNNER_VERSION=$(curl -fsSL https://data.forgejo.org/api/v1/repos/forgejo/runner/releases/latest | jq -r .name | sed 's/^v//') +curl -fsSL "https://code.forgejo.org/forgejo/runner/releases/download/v${RUNNER_VERSION}/forgejo-runner-${RUNNER_VERSION}-linux-${ARCH}" -o /usr/local/bin/forgejo-runner +chmod +x /usr/local/bin/forgejo-runner +msg_ok "Installed Forgejo Runner" + +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 "Registered Forgejo Runner" + +msg_info "Creating Services" +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 enable -q --now forgejo-runner +msg_ok "Created Services" + +motd_ssh +customize +cleanup_lxc