Files
userbase/.gitea/workflows/deploy-front.yml
T
chenxing c2e7b8f12a
deploy-userbase-front / build-and-deploy (push) Successful in 29s
fix(deploy): correct dist nesting + capture host-readable diagnostics
2026-08-04 23:06:47 +08:00

56 lines
2.6 KiB
YAML
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.
name: deploy-userbase-front
on:
push:
branches: [main]
paths:
- 'front/**'
- '.gitea/workflows/deploy-front.yml'
workflow_dispatch:
jobs:
build-and-deploy:
runs-on: ubuntu-latest
# node:20 自带 npm 与 git;通过已配置的 registry-mirrors 拉取
# /data/www/userbase 与 docker.sock 由 act_runner 全局 options 统一挂载(见 act-runner config)
container:
image: node:20
# 注意:本环境 act_runner v0.6.1 既不生效 container.options 的额外 --volume,
# 也不生效 workflow 的 container.volumes(自定义卷被静默忽略),
# 但它会默认把宿主 docker.sock 挂入每个 job 容器。
# 因此部署改用 scripts/deploy-via-docker.js:通过该 docker.sock 启动一次性
# helper 容器,把构建产物拷到宿主 /data/www/userbase/front。
steps:
# 内网 Gitea 无法访问 github.com 拉取 actions/checkout,改为直接 clone 本仓库
- name: Checkout (manual, internal Gitea)
run: |
git clone --depth 1 --branch main http://192.168.10.160:3000/${GITHUB_REPOSITORY}.git /tmp/src
cp -a /tmp/src/. .
rm -rf /tmp/src
- name: Use npm mirror (npmmirror)
working-directory: front
run: npm config set registry https://registry.npmmirror.com
# node-sass(6.x) 无 Node20 预编译二进制,源码编译必失败;项目实际用 dart-sass(sass)。
# 本地 lockfile 暂不便修改,这里在 runner 内把它从 lockfile 剔除后再 npm ci(不改仓库文件)。
- name: Strip node-sass from lockfile (CI-only)
run: |
node -e "const fs=require('fs');const p='front/package-lock.json';const d=JSON.parse(fs.readFileSync(p,'utf8'));const pk=d.packages||{};for(const k of Object.keys(pk)){if(k==='node_modules/node-sass'||k.startsWith('node_modules/node-sass/'))delete pk[k];}if(d.dependencies&&d.dependencies.node-sass)delete d.dependencies.node-sass;fs.writeFileSync(p,JSON.stringify(d,null,2));"
echo "node-sass stripped from lockfile"
- name: Install dependencies
working-directory: front
run: npm ci --no-audit --no-fund
- name: Build (prod -> dist/prod)
working-directory: front
run: npm run build:prod
- name: Deploy to static dir (/data/www/userbase/front)
# act_runner 不挂载自定义卷,改用宿主 docker.sock 启动一次性 helper 容器拷贝产物。
run: node scripts/deploy-via-docker.js
- name: Done
run: 'echo "deploy step finished; inspect host /data/www/userbase/_debug.txt for the full report"'