Files
sgame-admin-deploy/ci-runner-entry.sh
2026-06-11 11:12:14 +00:00

45 lines
1.5 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# Gitea Actions runner 容器入口(在 node:20-bookworm 镜像内执行)。
# NAS compose 的 ci-runner 服务启动时从公开产物仓 curl 本脚本执行——
# 改本文件 + 发版 + 重启 ci-runner 容器即可更新 runner 逻辑。
# /data 是持久卷Go 工具链、模块/构建缓存、act_runner 注册状态都在里面,
# 容器重建不丢。需要环境变量 RUNNER_REG_TOKEN仅首次注册时使用
set -e
# runner v1.x 要求 go>=1.261.26 向下兼容编译 go.mod 1.25 的项目
GO_VERSION=1.26.4
# v1.x 起模块改名 gitea.com/gitea/runner旧名 act_runner 装不上),二进制名也是 runner
RUNNER_VERSION=v1.0.8
export GOPATH=/data/gopath
export GOMODCACHE=/data/gomod
export GOCACHE=/data/gocache
export GOPROXY=https://goproxy.cn,direct
export PATH=/data/go/bin:$GOPATH/bin:$PATH
if [ ! -x /data/go/bin/go ]; then
echo "[ci-runner] downloading go $GO_VERSION ..."
curl -fsSL -o /tmp/go.tgz "https://mirrors.aliyun.com/golang/go${GO_VERSION}.linux-amd64.tar.gz"
tar -C /data -xzf /tmp/go.tgz
rm /tmp/go.tgz
fi
if [ ! -x "$GOPATH/bin/runner" ]; then
echo "[ci-runner] installing gitea runner $RUNNER_VERSION ..."
go install "gitea.com/gitea/runner@${RUNNER_VERSION}"
fi
mkdir -p /data/runner
cd /data/runner
if [ ! -f .runner ]; then
echo "[ci-runner] registering ..."
runner register --no-interactive \
--instance https://git.xindiegaming.top \
--token "$RUNNER_REG_TOKEN" \
--name nas-runner \
--labels nas:host
fi
echo "[ci-runner] daemon up"
exec runner daemon