ci(deploy): runs-on 对齐 runner 标签,部署目录改为生产实际路径
All checks were successful
CI / check (pull_request) Successful in 5m8s
Dependency Check / check (pull_request) Successful in 3m37s

runner(nonlocal-runner,个人级)注册标签为 ubuntu-latest 等,原 self-hosted
标签不匹配导致 job 无 runner 可派发。部署目录默认值 /opt/gongxue 改为生产
实际路径 /www/wwwroot/jidi.gongxue100.com(仍可用仓库变量 REMOTE_DIR 覆盖)
This commit is contained in:
2026-08-11 16:01:34 +08:00
parent 30d289875b
commit a0611fda25

View File

@@ -4,7 +4,7 @@
# 适用场景Gitea runner 与生产服务器同机(本机直跑,不需要 SSH/Secrets
#
# 前置准备:
# 1. Gitea Actions 已开启,且已注册 self-hosted runnerruns-on 标签与下面一致
# 1. Gitea Actions 已开启,且已注册 runnerruns-on 标签与 runner 实际标签一致,如 ubuntu-latest
# 2. 服务器已 clone 仓库到部署目录(默认 /opt/gongxue可用仓库 Variable REMOTE_DIR 覆盖)
# 3. 服务器已安装 Node 22 + PM2npm i -g pm2MySQL 已运行
# 4. runner 运行账户对部署目录有写权限、可执行 npm/pm2
@@ -37,30 +37,30 @@ concurrency:
jobs:
deploy:
runs-on: self-hosted # 改为你注册 runner 时使用的 label如 ubuntu-latest
runs-on: ubuntu-latest # 与已注册 runnernonlocal-runner的标签一致
steps:
- name: 拉取最新代码
run: |
cd ${{ vars.REMOTE_DIR || '/opt/gongxue' }}
cd ${{ vars.REMOTE_DIR || '/www/wwwroot/jidi.gongxue100.com' }}
git fetch origin
git checkout main
git pull origin main
- name: 安装依赖 & 构建
run: |
cd ${{ vars.REMOTE_DIR || '/opt/gongxue' }}
cd ${{ vars.REMOTE_DIR || '/www/wwwroot/jidi.gongxue100.com' }}
npm ci
npm run build -w @gongxue/server
npm run build -w @gongxue/admin
- name: 执行数据库迁移
run: |
cd ${{ vars.REMOTE_DIR || '/opt/gongxue' }}
cd ${{ vars.REMOTE_DIR || '/www/wwwroot/jidi.gongxue100.com' }}
npm run migration:run -w @gongxue/server
- name: PM2 重载
run: |
cd ${{ vars.REMOTE_DIR || '/opt/gongxue' }}
cd ${{ vars.REMOTE_DIR || '/www/wwwroot/jidi.gongxue100.com' }}
if [ "${{ github.event.inputs.seed_roles }}" = "true" ]; then
echo '>>> 强制播种 RBAC 权限码(本次进程带 SEED_ROLES=true'
SEED_ROLES=true pm2 startOrReload ecosystem.config.cjs --only gongxue-backend --update-env
@@ -73,7 +73,7 @@ jobs:
- name: 健康检查
run: |
cd ${{ vars.REMOTE_DIR || '/opt/gongxue' }}
cd ${{ vars.REMOTE_DIR || '/www/wwwroot/jidi.gongxue100.com' }}
sleep 3
# 从 .env 读 PORT默认 3000避免硬编码端口与后端不一致
PORT="$(grep '^PORT=' .env 2>/dev/null | cut -d= -f2- | tr -d '"' || true)"