#!/bin/bash source /opt/fefan/env.sh ## .env should define # ACT_RUNNER_USER: act_runner username (act_runner) # ACT_RUNNER_LOCATION: act_runner binary location (/usr/local/bin) # ACT_RUNNER_VERSION: act_runner version (0.2.13) # ENV_FILE_LOCATION: .env file location on vm (/opt/fefan/fefan.env) # GITEA_INSTANCE_URL: url of the gitea instance (https://gitea.aldon.fr) # GITEA_RUNNER_REGISTRATION_TOKEN: registration token for gitea runner (repository scope) # USERNAME: username of the vm (fefan) # REPOSITORY: repository on which service code is hosted (mop/fefan) if ! id -u $ACT_RUNNER_USER >/dev/null 2>&1; then adduser \ --system \ --shell /bin/bash \ --gecos 'Action runner user' \ --ingroup docker\ --disabled-password \ --home /home/$ACT_RUNNER_USER \ $ACT_RUNNER_USER fi wget -O $ACT_RUNNER_LOCATION/act_runner https://dl.gitea.com/act_runner/$ACT_RUNNER_VERSION/act_runner-$ACT_RUNNER_VERSION-linux-amd64 chmod +x $ACT_RUNNER_LOCATION/act_runner cat < /home/$ACT_RUNNER_USER/config.yaml log: level: info runner: file: .runner capacity: 1 timeout: 3h shutdown_timeout: 0s insecure: false fetch_timeout: 5s env_file: $ENV_FILE_LOCATION fetch_interval: 2s github_mirror: '' labels: - 'ubuntu-latest:docker://docker.gitea.com/runner-images:ubuntu-latest' - 'ubuntu-22.04:docker://docker.gitea.com/runner-images:ubuntu-22.04' - 'ubuntu-20.04:docker://docker.gitea.com/runner-images:ubuntu-20.04' cache: enabled: true dir: "" host: "" port: 0 external_server: "" container: network: "" privileged: false options: workdir_parent: valid_volumes: [] docker_host: "" force_pull: true force_rebuild: false require_docker: false docker_timeout: 0s host: workdir_parent: EOF cd /home/act_runner sudo -u $ACT_RUNNER_USER act_runner register --no-interactive --instance $GITEA_INSTANCE_URL --token $GITEA_RUNNER_REGISTRATION_TOKEN --name $USERNAME --labels $USERNAME chown -R $ACT_RUNNER_USER:docker /home/$ACT_RUNNER_USER