自己的服务器作 GitHub Action Runner

159 阅读1分钟

1. 打开任意仓库找到 Settings > Actions > Runners

右边绿色按钮 > 添加 Runner

image.png

2. 配置

根据 GitHub 给的 shell command 配置即可

Runner 不能在 root 用户跑, 如果你要用 root 跑, 带一个环境变量

RUNNER_ALLOW_RUNASROOT="1" ./conf... ./run.sh

我这里用了个 pm2 把 run.sh 挂后台了

脚本如下

#!/bin/bash
export RUNNER_ALLOW_RUNASROOT=1
export http_proxy=http://127.0.0.1:7890
export https_proxy=http://127.0.0.1:7890
export all_proxy=socks5://127.0.0.1:7890
./run.sh

image.png

3. 完成

在你的 ci yml 配置上 runs-on: [self-hosted, ...其他 runner 例如 ubuntu-latest] 就 OK 了

image.png

4. 其他

查看现存 runner 服务

ps -aux | grep runner