From f9a87a9993db2123fae4318eb3db860ff5590d6f Mon Sep 17 00:00:00 2001 From: wangjia <809946525@qq.com> Date: Tue, 7 Jul 2026 13:37:31 +0800 Subject: [PATCH] =?UTF-8?q?ci(site):=20deploy-site=20=E5=A2=9E=E8=A1=A5?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=B8=AD=E5=BF=83=E6=9E=84=E5=BB=BA+?= =?UTF-8?q?=E9=83=A8=E7=BD=B2(=E8=A1=A5=20CI=20=E7=BC=BA=E5=8F=A3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 用户中心此前无 CI 部署(手动 wrangler),漂移风险。现纳入 site-v* 发版: - scripts/ci/compile-usercenter.sh:next build → out/,⚠️内置 NEXT_PUBLIC_API_MODE=http + NEXT_PUBLIC_API_DOMAINS=https://api.yanmeiai.com(不设默认 mock=假数据,是个坑) - scripts/ci/deploy-usercenter.sh:wrangler pages deploy → pangolin-usercenter (app.yanmeiai.com) - deploy-site.yml 追加两步,官网+用户中心同一 tag 发,CF token/account 走全局 secret Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_013nMthbVEmQquxBRKb9Fj8u --- .gitea/workflows/deploy-site.yml | 11 +++++++++++ scripts/ci/compile-usercenter.sh | 22 ++++++++++++++++++++++ scripts/ci/deploy-usercenter.sh | 28 ++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100755 scripts/ci/compile-usercenter.sh create mode 100755 scripts/ci/deploy-usercenter.sh diff --git a/.gitea/workflows/deploy-site.yml b/.gitea/workflows/deploy-site.yml index 560cb89..201b5d0 100644 --- a/.gitea/workflows/deploy-site.yml +++ b/.gitea/workflows/deploy-site.yml @@ -29,3 +29,14 @@ jobs: CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} run: bash scripts/ci/deploy-site.sh + + # 用户中心(web/usercenter → CF Pages pangolin-usercenter / app.yanmeiai.com)。 + # 与官网同一发版(site-v*),避免两处各自漂移。⚠️ 必须 http 模式构建(见脚本)。 + - name: Compile (用户中心 Next.js) + run: bash scripts/ci/compile-usercenter.sh + + - name: Deploy usercenter → Cloudflare Pages + env: + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + run: bash scripts/ci/deploy-usercenter.sh diff --git a/scripts/ci/compile-usercenter.sh b/scripts/ci/compile-usercenter.sh new file mode 100755 index 0000000..b7d6202 --- /dev/null +++ b/scripts/ci/compile-usercenter.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +# compile-usercenter.sh — build the Next.js 用户中心 (web/usercenter) as a static +# export (output: web/usercenter/out/). Deployed to Cloudflare Pages +# (project pangolin-usercenter, 自定义域 app.yanmeiai.com) by deploy-usercenter.sh. +# +# ⚠️ 必须以「真实 API」模式构建:NEXT_PUBLIC_API_MODE=http。否则 lib/api/client.ts +# 默认落到 mock(内存假数据),部署上去登录/订阅全是演示数据。API 域名是公开信息 +# (非密钥,经 CF Tunnel 暴露的控制面),故此处内置默认值;可用同名 env 覆盖。 +# +# 由 .gitea/workflows/deploy-site.yml 在 ubuntu runner 上调用,从 repo 根运行。 +set -euo pipefail + +export NEXT_PUBLIC_API_MODE="${NEXT_PUBLIC_API_MODE:-http}" +export NEXT_PUBLIC_API_DOMAINS="${NEXT_PUBLIC_API_DOMAINS:-https://api.yanmeiai.com}" +echo "==> compile-usercenter: API_MODE=${NEXT_PUBLIC_API_MODE} API_DOMAINS=${NEXT_PUBLIC_API_DOMAINS}" + +cd web/usercenter +npm ci +npm run build + +echo "==> compile-usercenter: done — out/ contents:" +ls -lh out/ | head diff --git a/scripts/ci/deploy-usercenter.sh b/scripts/ci/deploy-usercenter.sh new file mode 100755 index 0000000..fc6f337 --- /dev/null +++ b/scripts/ci/deploy-usercenter.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# deploy-usercenter.sh — 部署 Next.js 用户中心 (web/usercenter/out/) 到 Cloudflare +# Pages(项目 pangolin-usercenter,自定义域 app.yanmeiai.com)。纯静态导出,全程 +# HTTPS,不落 VPS,与节点 :443(sing-box)无冲突。 +# +# 需环境变量: +# CLOUDFLARE_API_TOKEN 带 Account > Cloudflare Pages > Edit 权限的 CF token +# CLOUDFLARE_ACCOUNT_ID CF 账户 ID +# 由 compile-usercenter.sh 先产出 web/usercenter/out/;从 repo 根调用。 +set -euo pipefail + +if [ ! -d web/usercenter/out ]; then + echo "==> deploy-usercenter: web/usercenter/out/ 不存在 — 拒绝部署" >&2 + exit 1 +fi +if ! find web/usercenter/out -mindepth 1 -print -quit | grep -q .; then + echo "==> deploy-usercenter: web/usercenter/out/ 为空 — 拒绝部署" >&2 + exit 1 +fi + +: "${CLOUDFLARE_API_TOKEN:?deploy-usercenter: CLOUDFLARE_API_TOKEN 未设(需带 Pages:Edit)}" +: "${CLOUDFLARE_ACCOUNT_ID:?deploy-usercenter: CLOUDFLARE_ACCOUNT_ID 未设}" + +echo "==> deploy-usercenter: wrangler pages deploy → project pangolin-usercenter (branch main)" +npx --yes wrangler@4 pages deploy web/usercenter/out \ + --project-name=pangolin-usercenter --branch=main --commit-dirty=true + +echo "==> deploy-usercenter: done"