name: deploy-userbase-front on: push: branches: [main] paths: - 'front/**' - '.gitea/workflows/deploy-front.yml' jobs: build-and-deploy: runs-on: ubuntu-latest # node:20 自带 npm 与 git;通过已配置的 registry-mirrors 拉取 container: image: node:20 # 显式把宿主静态目录挂进 job 容器(act_runner 会校验 valid_volumes 白名单) volumes: - /data/www/userbase:/data/www/userbase 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 - name: Install dependencies working-directory: front run: npm ci - name: Build (prod -> dist/prod) working-directory: front run: npm run build:prod - name: Deploy to static dir (/data/www/userbase/front) # /data/www/userbase 已由 job container.volumes 挂入本容器 run: | rm -rf /data/www/userbase/front mkdir -p /data/www/userbase/front cp -r front/dist/prod/. /data/www/userbase/front/ echo "deployed front -> /data/www/userbase/front" - name: Done run: ls -la /data/www/userbase/front | head