🗃️ Committing everything that changed 🗃️
Some checks are pending
release-tag / release-image (push) Waiting to run

rootfs/tmp/etc/act_runner/cache_server.yaml
rootfs/tmp/etc/act_runner/daemon.yaml
rootfs/tmp/etc/act_runner/default_config.yaml
rootfs/tmp/etc/act_runner/multi.yaml
rootfs/usr/local/etc/docker/init.d/zz-act_runner.sh
This commit is contained in:
casjay 2024-09-02 11:07:50 -04:00
parent 9cec457137
commit 50d7c85076
Signed by untrusted user who does not match committer: jason
GPG Key ID: 1AB309F42A764145
4 changed files with 65 additions and 109 deletions

View File

@ -0,0 +1,9 @@
log:
# The level of logging, can be trace, debug, info, warn, error, fatal
level: info
cache:
# Enable cache server to use actions/cache.
enabled: true
# The directory to store the cache data.
dir: '/data/act_runner/cache'

View File

@ -1,78 +0,0 @@
# Config for act_runner daemon
log:
# The level of logging, can be trace, debug, info, warn, error, fatal
level: info
host:
# The parent directory of a job's working directory.
workdir_parent: '/tmp/act_runner'
runner:
# Where to store the registration result.
file: /config/act_runner/runners
# Execute how many tasks concurrently at the same time.
capacity: 5
# Extra environment variables to run jobs.
envs:
A_TEST_ENV_NAME_1: a_test_env_value_1
# Extra environment variables to run jobs from a file.
env_file: .env
# The timeout for a job to be finished.
timeout: 3h
# Whether skip verifying the TLS certificate of the Gitea instance.
insecure: true
# The timeout for fetching the job from the Gitea instance.
fetch_timeout: 5s
# The interval for fetching the job from the Gitea instance.
fetch_interval: 2s
# The labels of a runner are used to determine which jobs the runner can run, and how to run them.
labels:
#- 'macos:docker:dockurr/macos'
#- 'windows:docker:dockurr/windows'
#- 'linux:docker:casjaysdev/almalinux'
#- 'alma:docker:casjaysdev/almalinux'
#- 'alpine:docker:casjaysdev/alpine'
#- 'debian:docker:casjaysdev/debian'
#- 'arch:docker:casjaysdev/archlinux'
#- 'node:docker://node:latest'
#- 'node14:docker://node:14'
#- 'node16:docker://node:16'
#- 'node18:docker://node:18'
#- 'node20:docker://node:20'
#- 'node20:docker://node:20'
#- 'python3:docker://python:latest'
#- 'php7:docker://php:7-fpm'
#- 'php8:docker://php:8-fpm'
#- 'php:docker://php:8.4-rc-fpm-alpine3.20'
#- 'alpine:docker://casjaysdev/alpine:latest'
#- 'almalinux:docker://casjaysdev/almalinux:latest'
#- 'debian:docker://casjaysdev/debian:latest'
#- 'ubuntu:docker://casjaysdev/ubuntu:latest'
#- 'linux:host,ubuntu-latest:docker://catthehacker/ubuntu:full-latest'
container:
# Specifies the network to which the container will connect.
network: 'bridge'
# Whether to use privileged mode or not when launching task containers (privileged mode is required for Docker-in-Docker).
privileged: true
# And other options to be used when the container is started (eg, --add-host=my.gitea.url:host-gateway).
options:
# The parent directory of a job's working directory.
workdir_parent: '/tmp/act_runner/volumes'
# Volumes (including bind mounts) can be mounted to containers. Glob syntax is supported, see https://github.com/gobwas/glob
valid_volumes:
- '**'
# overrides the docker client host with the specified one.
docker_host: ''
cache:
# Enable cache server to use actions/cache.
enabled: true
# The directory to store the cache data.
dir: '/data/act_runner/cache'
# The host of the cache server.
host: ''
# The port of the cache server.
port: 0
# The external cache server URL. Valid only when enable is true.
external_server: ''

View File

@ -64,3 +64,11 @@ container:
- '**'
# overrides the docker client host with the specified one.
docker_host: ''
cache:
# Enable cache server to use actions/cache.
enabled: true
# The host of the cache server.
host: 'REPLACE_RUNNER_CACHE_HOST'
# The port of the cache server.
port: REPLACE_RUNNER_CACHE_PORT

View File

@ -128,9 +128,9 @@ SERVICE_GROUP="git" # Set the service group
#SERVICE_GID="0" # set the group id
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# execute command variables - keep single quotes variables will be expanded later
EXEC_CMD_BIN='act_runner' # command to execute
EXEC_CMD_ARGS='daemon --config $ETC_DIR/daemon.yaml' # command arguments
EXEC_PRE_SCRIPT='' # execute script before
EXEC_CMD_BIN='act_runner' # command to execute
EXEC_CMD_ARGS='daemon --config $ETC_DIR/default_config.yaml' # command arguments
EXEC_PRE_SCRIPT='' # execute script before
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Is this service a web server
IS_WEB_SERVER="no"
@ -202,7 +202,9 @@ ADDITIONAL_CONFIG_DIRS=""
CMD_ENV=""
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Overwrite based on file/directory
RUNNER_CACHE_HOST="${RUNNER_CACHE_HOST:-localhost}"
RUNNER_CACHE_PORT="${RUNNER_CACHE_PORT:-$SERVICE_PORT}"
RUNNER_CONFIG_NAME="${RUNNER_CONFIG_NAME:-runner.yaml}"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Per Application Variables or imports
@ -229,20 +231,24 @@ __run_pre_execute_checks() {
{
[ -d "$CONF_DIR/reg" ] || mkdir -p "$CONF_DIR/reg"
[ -d "$DATA_DIR/cache" ] || mkdir -p "$DATA_DIR/cache"
[ -f "$ETC_DIR/multi.yaml" ] && [ ! -f "$CONF_DIR/multi.yaml" ] && copy "$ETC_DIR/multi.yaml" "$CONF_DIR/multi.yaml"
[ -f "$ETC_DIR/daemon.yaml" ] && [ ! -f "$CONF_DIR/daemon.yaml" ] && copy "$ETC_DIR/daemon.yaml" "$CONF_DIR/daemon.yaml"
[ -f "$ETC_DIR" ] && [ ! -f "" ] && cp -Rf "$ETC_DIR/." "$CONF_DIR/"
if [ ! -f "$CONF_DIR/reg/default.sample" ]; then
cat <<EOF >"$CONF_DIR/reg/default.sample"
# Edit this file and execute it
RUNNER_NAME="gitea"
RUNNER_HOME="$CONF_DIR"
exitStatus=1
RUNNER_NAME="default"
RUNNER_HOME="$HOME/.config/act_runner"
RUNNER_LABELS="$RUNNER_LABELS"
RUNNER_AUTH_TOKEN="${RUNNER_AUTH_TOKEN:-$SYS_AUTH_TOKEN}"
RUNNER_HOSTNAME="${INSTANCE_HOSTNAME}"
RUNNER_REGISTER_URL="http://\${INSTANCE_HOSTNAME}"
act_runner register --config "\$RUNNER_HOME/daemon.yaml" --labels "\$RUNNER_LABELS" --name "\$RUNNER_NAME" --instance "\$RUNNER_REGISTER_URL" --token "\$RUNNER_AUTH_TOKEN" --no-interactive && exitStatus=0 || exitStatus=1
exit \$exitStatus
RUNNER_REGISTER_URL="http://\${RUNNER_HOSTNAME}"
mkdir -p "\$RUNNER_HOME"
[ -f \$RUNNER_HOME/config.yaml" ] || act_runner generate-config >"\$RUNNER_HOME/config.yaml"
act_runner register --config "\$RUNNER_HOME/config.yaml" --labels "\$RUNNER_LABELS" --name "\$RUNNER_NAME" --instance "\$RUNNER_REGISTER_URL" --token "\$RUNNER_AUTH_TOKEN" --no-interactive && exitStatus=0 || exitStatus=1
if [ "\$exitStatus" -eq 0 ]; then
act_runner daemon --config $"\$RUNNER_HOME/config.yaml" &
exitStatus=\$?
fi
exit \$exitStatus
EOF
chmod -Rf 755 "$CONF_DIR/reg/default.sample"
@ -272,10 +278,16 @@ RUNNER_LABELS="$RUNNER_LABELS"
EOF
fi
if [ -f "$CONF_DIR/daemon.yaml" ]; then
if [ ! -f "$CONF_DIR/runners" ] && [ -n "$SYS_AUTH_TOKEN" ]; then
echo "creating gitea in $CONF_DIR and registering with http://$INSTANCE_HOSTNAME"
act_runner register --config "$CONF_DIR/daemon.yaml" --labels "$RUNNER_LABELS" --name "gitea" --instance "http://127.0.0.1:$GITEA_PORT" --token "$SYS_AUTH_TOKEN" --no-interactive 2>/dev/stdout
if [ -f "$ETC_DIR/default_config.yaml" ]; then
mkdir -p "$CONF_DIR/default"
[ -f "$CONF_DIR/default/$RUNNER_CONFIG_NAME" ] || copy "$ETC_DIR/default_config.yaml" "$CONF_DIR/default/$RUNNER_CONFIG_NAME"
if [ ! -f "$ETC_DIR/runners" ] && [ -f "$CONF_DIR/default/$RUNNER_CONFIG_NAME" ] && [ -n "$SYS_AUTH_TOKEN" ]; then
__replace "REPLACE_RUNNER_TEMP" "$TMP_DIR/gitea" "$CONF_DIR/default/$RUNNER_CONFIG_NAME"
__replace "REPLACE_RUNNER_HOME" "$CONF_DIR/default" "$CONF_DIR/default/$RUNNER_CONFIG_NAME"
__replace "REPLACE_RUNNER_CACHE_HOST" "$RUNNER_CACHE_HOST" "$CONF_DIR/default/$RUNNER_CONFIG_NAME"
__replace "REPLACE_RUNNER_CACHE_PORT" "$RUNNER_CACHE_PORT" "$CONF_DIR/default/$RUNNER_CONFIG_NAME"
echo "creating gitea in $CONF_DIR/default and registering with http://$INSTANCE_HOSTNAME"
act_runner register --config "$CONF_DIR/default/$RUNNER_CONFIG_NAME" --labels "$RUNNER_LABELS" --name "gitea" --instance "http://127.0.0.1:$GITEA_PORT" --token "$SYS_AUTH_TOKEN" --no-interactive 2>/dev/stdout
fi
fi
@ -308,11 +320,13 @@ EOF
sleep 120
else
echo "creating $RUNNER_NAME in $RUNNER_HOME and registering with $RUNNER_REGISTER_URL"
[ -f "$RUNNER_HOME/daemon.yaml" ] || copy "$ETC_DIR/multi.yaml" "$RUNNER_HOME/daemon.yaml"
__replace "REPLACE_RUNNER_HOME" "$RUNNER_HOME" "$RUNNER_HOME/daemon.yaml"
__replace "REPLACE_RUNNER_TEMP" "$TMP_DIR/$RUNNER_NAME" "$RUNNER_HOME/daemon.yaml"
if grep -sq "$RUNNER_HOME" "$RUNNER_HOME/daemon.yaml" && grep -sq "$TMP_DIR/$RUNNER_NAME" "$RUNNER_HOME/daemon.yaml"; then
act_runner register --config "$RUNNER_HOME/daemon.yaml" --labels "$RUNNER_LABELS" --name "$RUNNER_NAME" --instance "$RUNNER_REGISTER_URL" --token "$RUNNER_AUTH_TOKEN" --no-interactive 2>/dev/stdout
[ -f "$RUNNER_HOME/$RUNNER_CONFIG_NAME" ] || copy "$ETC_DIR/default_config.yaml" "$RUNNER_HOME/$RUNNER_CONFIG_NAME"
__replace "REPLACE_RUNNER_HOME" "$RUNNER_HOME" "$RUNNER_HOME/$RUNNER_CONFIG_NAME"
__replace "REPLACE_RUNNER_TEMP" "$TMP_DIR/$RUNNER_NAME" "$RUNNER_HOME/$RUNNER_CONFIG_NAME"
__replace "REPLACE_RUNNER_CACHE_HOST" "$RUNNER_CACHE_HOST" "$RUNNER_HOME/$RUNNER_CONFIG_NAME"
__replace "REPLACE_RUNNER_CACHE_PORT" "$RUNNER_CACHE_PORT" "$RUNNER_HOME/$RUNNER_CONFIG_NAME"
if grep -sq "$RUNNER_HOME" "$RUNNER_HOME/$RUNNER_CONFIG_NAME" && grep -sq "$TMP_DIR/$RUNNER_NAME" "$RUNNER_HOME/$RUNNER_CONFIG_NAME"; then
act_runner register --config "$RUNNER_HOME/$RUNNER_CONFIG_NAME" --labels "$RUNNER_LABELS" --name "$RUNNER_NAME" --instance "$RUNNER_REGISTER_URL" --token "$RUNNER_AUTH_TOKEN" --no-interactive 2>/dev/stdout
if [ $? -eq 0 ] || [ -f "$RUNNER_HOME/runners" ]; then
copy "$runner" "$RUNNER_HOME/$RUNNER_NAME.reg"
chown -Rf "$SERVICE_USER":"$SERVICE_GROUP" "$RUNNER_HOME"
@ -326,7 +340,7 @@ EOF
fi
else
exitStatus=$((exitStatus++))
echo "Something seems to have gone wrong modifying $RUNNER_HOME/daemon.yaml" >&2
echo "Something seems to have gone wrong modifying $RUNNER_HOME/$RUNNER_CONFIG_NAME" >&2
fi
fi
unset RUNNER_HOME RUNNER_NAME RUNNER_AUTH_TOKEN RUNNER_HOSTNAME RUNNER_REGISTER_URL
@ -418,11 +432,13 @@ __post_execute() {
# show message
__banner "$postMessageST"
# commands to execute
if [ -f "$CONF_DIR/runners" ] && [ -f "$CONF_DIR/daemon.yaml" ]; then
act_runner daemon --config $CONF_DIR/daemon.yaml &
if [ -f "$CONF_DIR/default/runners" ] && [ -f "$CONF_DIR/default/$RUNNER_CONFIG_NAME" ]; then
act_runner daemon --config $CONF_DIR/default/$RUNNER_CONFIG_NAME &
pid=$!
sleep 5 && ps ax | awk '{print $1}' | grep -v 'grep' | grep -q "$pid$" && is_running="yes"
if [ "$is_running" = "yes" ]; then
echo "$(date)" >"$CONF_DIR/.runner"
echo "$$" >"$RUN_DIR/act_runner.pid"
echo "$pid" >"$RUN_DIR/act_runner.gitea.pid"
echo "Runner: gitea has been started with pid: $pid" | tee -a -p "$LOG_DIR/init.txt"
else
@ -435,8 +451,9 @@ __post_execute() {
for multi_dir in "$CONF_DIR/multi"/*; do
if [ -n "$multi_dir" ] && [ -d "$multi_dir" ]; then
name="$(basename "$multi_dir")"
if [ -f "$multi_dir/daemon.yaml" ] && [ -f "$multi_dir/runners" ]; then
act_runner daemon --config $multi_dir/daemon.yaml &
conf="$multi_dir/$RUNNER_CONFIG_NAME"
if [ -f "$conf" ] && [ -f "$multi_dir/runners" ]; then
act_runner daemon --config $conf &
pid=$!
sleep 5 && ps ax | awk '{print $1}' | grep -v 'grep' | grep -q "$pid$" && is_running="yes"
if [ "$is_running" = "yes" ]; then
@ -451,11 +468,11 @@ __post_execute() {
unset pid is_running name
done
fi
echo "$(date)" >"$CONF_DIR/.runner"
echo "$$" >"$RUN_DIR/act_runner.pid"
act_runner cache-server --config $CONF_DIR/daemon.yaml -s 0.0.0.0 -p $SERVICE_PORT 2>>/dev/stderr | tee -a -p "$LOG_DIR/act_runner_cache.log" &
execPid=$!
sleep 5 && ps ax | awk '{print $1}' | grep -v grep | grep -q "$execPid$" && return 0 || return 2
if [ -f "$CONF_DIR/cache_server.yaml" ]; then
act_runner cache-server --config $CONF_DIR/cache_server.yaml -s 0.0.0.0 -p $RUNNER_CACHE_PORT 2>>/dev/stderr | tee -a -p "$LOG_DIR/act_runner_cache.log" &
execPid=$!
sleep 5 && ps ax | awk '{print $1}' | grep -v grep | grep -q "$execPid$" && return 0 || return 2
fi
# show exit message
__banner "$postMessageEnd: Status $retVal"
) 2>"/dev/stderr" | tee -p -a "$LOG_DIR/init.txt" &