## Self-hosted runner ### Download Linux x64 ```shell # Create a folder $ mkdir actions-runner && cd actions-runner # Download the latest runner package $ curl -o actions-runner-linux-x64-2.337.0.tar.gz -L https://github.com/actions/runner/releases/download/v2.337.0/actions-runner-linux-x64-2.337.0.tar.gz # Optional: Validate the hash $ echo "70920811a4f8ad4328818682bca5c6469c1c942fab52448868071d0063816613 actions-runner-linux-x64-2.337.0.tar.gz" | shasum -a 256 -c Copied! # Extract the installer $ tar xzf ./actions-runner-linux-x64-2.337.0.tar.gz ``` ### Config ```shell # Create the runner and start the configuration experience $ ./config.sh --url https://github.com/OWNER/REPO --token TOKEN # Remove runner registration $ ./config.sh remove --token REMOVE_TOKEN # Last step, run it! $ ./run.sh ``` ### Service ```shell # Installing the service sudo ./svc.sh install # Starting the service sudo ./svc.sh start # 防止 Debian/Ubuntu 系统更新时,needrestart 自动重启服务,导致流水线中断 echo '$nrconf{override_rc}{qr(^actions\.runner\..+\.service$)} = 0;' | sudo tee /etc/needrestart/conf.d/actions_runner_services.conf # Checking the status sudo ./svc.sh status # Stopping the service sudo ./svc.sh stop # Uninstalling the service sudo ./svc.sh uninstall # View real-time logs journalctl -u 'actions.runner.*' -f ``` ### Docker 由于 runner 不能运行在 root 下,所以如果使用 docker 需要给普通用户加上权限 ```shell # 将 USERNAME 添加到 docker 用户组(需要 root 权限) usermod -aG docker USERNAME # 重启 Runner 服务,使新的用户组权限生效 sudo ./svc.sh stop sudo ./svc.sh start ``` ## 参考 - https://docs.github.com/en/actions/how-tos/manage-runners/self-hosted-runners/add-runners - https://docs.github.com/en/actions/how-tos/manage-runners/self-hosted-runners/configure-the-application?platform=linux