This commit is contained in:
Executable
+63
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env bash
|
||||
# 在部署机上一键安装 Gitea Act Runner(仅需执行一次)
|
||||
# 用法:
|
||||
# export GITEA_URL=https://gitea.yueqing.online
|
||||
# export RUNNER_TOKEN=从Gitea复制的注册Token
|
||||
# bash scripts/install-act-runner.sh
|
||||
set -euo pipefail
|
||||
|
||||
GITEA_URL="${GITEA_URL:?请设置 GITEA_URL,例如 https://gitea.yueqing.online}"
|
||||
RUNNER_TOKEN="${RUNNER_TOKEN:?请设置 RUNNER_TOKEN(Gitea → 仓库/站点 Actions → Runners → 创建)}"
|
||||
RUNNER_NAME="${RUNNER_NAME:-yingqing-ecs}"
|
||||
LABELS="${LABELS:-yingqing:host}"
|
||||
INSTALL_DIR="${INSTALL_DIR:-/opt/act_runner}"
|
||||
|
||||
mkdir -p "$INSTALL_DIR"
|
||||
cd "$INSTALL_DIR"
|
||||
|
||||
ARCH="$(uname -m)"
|
||||
case "$ARCH" in
|
||||
x86_64|amd64) ARCH=amd64 ;;
|
||||
aarch64|arm64) ARCH=arm64 ;;
|
||||
*) echo "不支持的架构: $ARCH"; exit 1 ;;
|
||||
esac
|
||||
|
||||
VER="${ACT_RUNNER_VERSION:-0.2.11}"
|
||||
BIN_URL="https://gitea.com/gitea/act_runner/releases/download/v${VER}/act_runner-${VER}-linux-${ARCH}"
|
||||
|
||||
echo "下载 act_runner v${VER} ..."
|
||||
curl -fL "$BIN_URL" -o act_runner
|
||||
chmod +x act_runner
|
||||
|
||||
if [[ ! -f .runner ]]; then
|
||||
echo "注册 Runner ..."
|
||||
./act_runner register --no-interactive \
|
||||
--instance "$GITEA_URL" \
|
||||
--token "$RUNNER_TOKEN" \
|
||||
--name "$RUNNER_NAME" \
|
||||
--labels "$LABELS"
|
||||
fi
|
||||
|
||||
cat >/etc/systemd/system/act_runner.service <<UNIT
|
||||
[Unit]
|
||||
Description=Gitea Act Runner
|
||||
After=network.target docker.service
|
||||
Wants=docker.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
WorkingDirectory=${INSTALL_DIR}
|
||||
ExecStart=${INSTALL_DIR}/act_runner daemon
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
UNIT
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl enable --now act_runner
|
||||
systemctl --no-pager --full status act_runner || true
|
||||
echo
|
||||
echo "完成。在 Gitea → Actions → Runners 应看到「${RUNNER_NAME}」在线,label: ${LABELS}"
|
||||
echo "可停掉旧的 webhook(避免重复部署):systemctl disable --now airshelf-webhook"
|
||||
Reference in New Issue
Block a user