add gitea runner
This commit is contained in:
11
gitea_runner/env.sh
Normal file
11
gitea_runner/env.sh
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
SERVICE_NAME="gitea_runner"
|
||||||
|
USER_SYSTEMD="$HOME/.config/systemd/user"
|
||||||
|
INSTALL_DIR="$HOME/.local/share/$SERVICE_NAME"
|
||||||
|
ADDITIONAL_LABLES=(
|
||||||
|
"linux"
|
||||||
|
"arm64"
|
||||||
|
"cloud"
|
||||||
|
)
|
||||||
|
CONTAINER_HOST="unix:////run/user/1000/podman/podman.sock"
|
||||||
|
GITEA_URL="https://gitea.example.com"
|
||||||
|
GITEA_TOKEN="your_gitea_token"
|
||||||
14
gitea_runner/gitea_runner.service.template
Normal file
14
gitea_runner/gitea_runner.service.template
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Gitea Actions runner
|
||||||
|
Documentation=https://gitea.com/gitea/act_runner
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=
|
||||||
|
ExecReload=/bin/kill -s HUP $MAINPID
|
||||||
|
WorkingDirectory=
|
||||||
|
TimeoutSec=0
|
||||||
|
RestartSec=10
|
||||||
|
Restart=always
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=default.target
|
||||||
66
gitea_runner/install.sh
Executable file
66
gitea_runner/install.sh
Executable file
@@ -0,0 +1,66 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# This script is used to install gitea act_runner
|
||||||
|
|
||||||
|
. ./env.sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
ARCH=$(uname -m)
|
||||||
|
echo "Architecture $ARCH"
|
||||||
|
DOWNLOAD_VARIANT=""
|
||||||
|
ACT_RUNNER_VERSION="0.2.11"
|
||||||
|
RUNNER="$INSTALL_DIR/act_runner"
|
||||||
|
|
||||||
|
if [[ "$ARCH" == "amd64" ]]; then
|
||||||
|
DOWNLOAD_VARIANT="amd64"
|
||||||
|
elif [[ "$ARCH" == "aarch64" ]]; then
|
||||||
|
DOWNLOAD_VARIANT="arm64"
|
||||||
|
else
|
||||||
|
echo "Unsupported architecture: $ARCH"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
DOWNLOAD_URL="https://dl.gitea.com/act_runner/$ACT_RUNNER_VERSION/act_runner-$ACT_RUNNER_VERSION-linux-$DOWNLOAD_VARIANT"
|
||||||
|
|
||||||
|
mkdir -p "$INSTALL_DIR"
|
||||||
|
|
||||||
|
wget -q "$DOWNLOAD_URL" -O "$RUNNER" || {
|
||||||
|
echo "Failed to download act_runner from $DOWNLOAD_URL"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
chmod +x "$INSTALL_DIR/act_runner"
|
||||||
|
echo "act_runner downloaded and made executable."
|
||||||
|
|
||||||
|
$RUNNER generate-config > "$INSTALL_DIR/config.yaml"
|
||||||
|
|
||||||
|
echo "act_runner config generated."
|
||||||
|
echo "act_runner config file created at $INSTALL_DIR/config.yaml"
|
||||||
|
|
||||||
|
echo "manually add additional labels to the config file - $INSTALL_DIR/config.yaml"
|
||||||
|
echo "add the following labels to the config file - $INSTALL_DIR/config.yaml"
|
||||||
|
for label in "${ADDITIONAL_LABLES[@]}"; do
|
||||||
|
echo " - $label"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "manually add docker socket to the config file - $INSTALL_DIR/config.yaml"
|
||||||
|
echo "add the following docker socket to the config file - $INSTALL_DIR/config.yaml"
|
||||||
|
echo " - $CONTAINER_HOST"
|
||||||
|
|
||||||
|
# Create systemd service file
|
||||||
|
SERVICE_FILE="${SERVICE_NAME}.service"
|
||||||
|
cp "$SERVICE_FILE.template" "$SERVICE_FILE"
|
||||||
|
|
||||||
|
ESC_RUNNER=$(printf '%s' "$RUNNER" | sed 's:/:\\/:g')
|
||||||
|
ESC_INSTALL_DIR=$(printf '%s' "$INSTALL_DIR" | sed 's:/:\\/:g')
|
||||||
|
|
||||||
|
sed -i "s|^ExecStart=.*$|ExecStart=${ESC_RUNNER} daemon --config ${ESC_INSTALL_DIR}/config.yaml|" "$SERVICE_FILE"
|
||||||
|
sed -i "s|^WorkingDirectory=.*$|WorkingDirectory=${ESC_INSTALL_DIR}|" "$SERVICE_FILE"
|
||||||
|
|
||||||
|
mv "$SERVICE_FILE" "$USER_SYSTEMD/$SERVICE_FILE"
|
||||||
|
systemctl --user daemon-reload
|
||||||
|
systemctl --user enable "${SERVICE_NAME}.service"
|
||||||
|
|
||||||
|
echo "Gitea act_runner installed and systemd service created."
|
||||||
|
echo "Before starting the service, please edit the config file - $INSTALL_DIR/config.yaml"
|
||||||
|
echo "and register the runner with your Gitea instance."
|
||||||
15
gitea_runner/uninstall.sh
Executable file
15
gitea_runner/uninstall.sh
Executable file
@@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# This script is used to uninstall Gitea act_runner
|
||||||
|
|
||||||
|
. ./env.sh
|
||||||
|
|
||||||
|
if systemctl --user list-units --full --all | grep -q "${SERVICE_NAME}.service"; then
|
||||||
|
systemctl --user stop "${SERVICE_NAME}.service"
|
||||||
|
fi
|
||||||
|
|
||||||
|
systemctl --user disable --now "${SERVICE_NAME}.service"
|
||||||
|
rm "$USER_SYSTEMD/${SERVICE_NAME}.service"
|
||||||
|
systemctl --user daemon-reload
|
||||||
|
|
||||||
|
echo "Uninstall complete. Manually remove data directory - $INSTALL_DIR if needed."
|
||||||
Reference in New Issue
Block a user