'Generic Commit'

This commit is contained in:
Your Name 2025-06-01 16:09:46 +12:00
parent 41287ec041
commit 86bae74779
8 changed files with 125 additions and 0 deletions

View File

@ -0,0 +1,10 @@
# DO NOT EDIT THIS FILE FOR YOUR SERVICE!
# This file is replaced from the template whenever there is an update.
# Edit the service.env file to make changes.
# Template to use - always required!
TEMPLATE=gitea-runner
REQUIRES_HOST_ROOT=false
REQUIRES_DOCKER=true
REQUIRES_DOCKER_ROOT=true

View File

@ -0,0 +1,10 @@
# Service settings specific to this server
# (can also override anything in the .template_info.env file in the template to make it specific to this server)
# $HOME etc expanded on remote server by bash.
GITEA_RUNNER_DIRECTORY="${HOME}/.gitea-runner"
ACT_RUNNER_VERSION="0.2.11"
GITEA_URL="https://gitea.jde.nz"
GITEA_TOKEN="GITEA_TOKEN"
GITEA_RUNNER_NAME="${SERVER}-${SERVICE}"
GITEA_RUNNER_LABELS="ubuntu-latest:docker://node:16-bullseye,ubuntu-22.04:docker://node:16-bullseye,ubuntu-20.04:docker://node:16-bullseye,ubuntu-18.04:docker://node:16-buster"

10
gitea-runner/destroy.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash
set -euo pipefail
# shellcheck disable=SC1091
source "${AGENT_PATH}/common.sh"
_check_required_env_vars "SERVER" "SERVICE" "GITEA_RUNNER_DIRECTORY"
# Call uninstall script first
./uninstall.sh
echo "Destroyed ${CONTAINER_NAME}."

31
gitea-runner/install.sh Executable file
View File

@ -0,0 +1,31 @@
#!/bin/bash
set -euo pipefail
# shellcheck disable=SC1091
source "${AGENT_PATH}/common.sh"
_check_required_env_vars "SERVER" "SERVICE" "TEMP_DIR" "GITEA_RUNNER_DIRECTORY" "ACT_RUNNER_VERSION"
echo "Downloading act_runner ${ACT_RUNNER_VERSION}..."
wget https://gitea.com/gitea/act_runner/releases/download/v${ACT_RUNNER_VERSION}/act_runner-${ACT_RUNNER_VERSION}-linux-amd64 -O "${TEMP_DIR}/act_runner"
chmod +x "${TEMP_DIR}/act_runner" || _die "Failed to download ${TEMP_DIR}/act_runner"
ACT_RUNNER="${GITEA_RUNNER_DIRECTORY}/act_runner"
mkdir -p "${GITEA_RUNNER_DIRECTORY}" || _die "Failed to create ${GITEA_RUNNER_DIRECTORY}"
cp "${TEMP_DIR}/act_runner" "$ACT_RUNNER" || _die "Failed to copy ${TEMP_DIR}/act_runner to ${GITEA_RUNNER_DIRECTORY}/act_runner"
${ACT_RUNNER} --version || _die "Failed to run ${ACT_RUNNER}"
${ACT_RUNNER} generate-config > "${GITEA_RUNNER_DIRECTORY}/config.yaml" || _die "Failed to generate config.yaml"
${ACT_RUNNER} --config "${GITEA_RUNNER_DIRECTORY}/config.yaml" \
register --no-interactive \
--instance GITEA_URL \
--token "${GITEA_TOKEN}" \
--name "${GITEA_RUNNER_NAME}" \
--labels "${GITEA_RUNNER_LABELS}"
./start.sh || _die "Failed to start"
echo "Installation complete for service ${SERVICE}."

18
gitea-runner/start.sh Executable file
View File

@ -0,0 +1,18 @@
#!/bin/bash
set -euo pipefail
# shellcheck disable=SC1091
source "${AGENT_PATH}/common.sh"
_check_required_env_vars "SERVER" "SERVICE" "GITEA_RUNNER_DIRECTORY"
# START SCRIPT
# The start script is required for all templates.
# It is used to start the service on the server.
# It is called with the path to the server specific env file as an argument.
CONFIG_FILE="${GITEA_RUNNER_DIRECTORY}/config.yaml"
"${GITEA_RUNNER_DIRECTORY}/act_runner" daemon --config "${CONFIG_FILE}" || _die "Failed to start act_runner"
echo "act_runner started"

15
gitea-runner/status.sh Executable file
View File

@ -0,0 +1,15 @@
#!/bin/bash
set -euo pipefail
# shellcheck disable=SC1091
source "${AGENT_PATH}/common.sh"
_check_required_env_vars "SERVER" "SERVICE" "GITEA_RUNNER_DIRECTORY"
# check if the act_runner process is running
if ! pgrep -f "${GITEA_RUNNER_DIRECTORY}/act_runner" > /dev/null; then
echo "act_runner is not running"
exit 1
fi
echo "act_runner is running"
exit 0

16
gitea-runner/stop.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/bash
set -euo pipefail
# shellcheck disable=SC1091
source "${AGENT_PATH}/common.sh"
_check_required_env_vars "SERVER" "SERVICE" "GITEA_RUNNER_DIRECTORY"
# kill the act_runner process
pkill -f "${GITEA_RUNNER_DIRECTORY}/act_runner"
echo "act_runner stopped"

15
gitea-runner/uninstall.sh Executable file
View File

@ -0,0 +1,15 @@
#!/bin/bash
set -euo pipefail
# shellcheck disable=SC1091
source "${AGENT_PATH}/common.sh"
_check_required_env_vars "SERVER" "SERVICE" "GITEA_RUNNER_DIRECTORY"
echo "Uninstalling service ${SERVICE}..."
./stop.sh || _die "Failed to stop act_runner"
rm -rf "${GITEA_RUNNER_DIRECTORY}"
echo "Service ${SERVICE} uninstalled."
echo "Note: This does NOT remove the local data folder. Use destroy for that."