refactor(ci): 官网部署改用 Cloudflare Pages(替代 rsync 到 pangolin1)

节点 :443 被 sing-box(VPN 数据面)占用,CF 免费套餐回源只能打 :80/:443、改端口需
Enterprise —— 故官网改由 CF Pages 托管(项目 pangolin-site,自定义域 pangolin.yanmeiai.com),
纯静态、全程 HTTPS、_headers/CSP 自动生效、不落 VPS、彻底无 :443 冲突。
deploy-site.sh 改为 wrangler pages deploy(需 CLOUDFLARE_API_TOKEN + CLOUDFLARE_ACCOUNT_ID
Gitea secret);deploy-site.yml deploy 步骤在 node:20 容器内跑 wrangler。lib-ssh 仍供服务端部署用。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
wangjia
2026-07-06 09:59:58 +08:00
parent 443d4e3a11
commit 673914783d
2 changed files with 24 additions and 23 deletions
+7 -3
View File
@@ -23,7 +23,11 @@ jobs:
-e SITE_URL=https://pangolin.yanmeiai.com \
node:20 bash scripts/ci/compile-site.sh
- name: Deploy → pangolin1
- name: Deploy → Cloudflare Pages
env:
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
run: bash scripts/ci/deploy-site.sh
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
run: |
docker run --rm -v "$PWD:/w" -w /w \
-e CLOUDFLARE_API_TOKEN -e CLOUDFLARE_ACCOUNT_ID \
node:20 bash scripts/ci/deploy-site.sh
+17 -20
View File
@@ -1,32 +1,29 @@
#!/usr/bin/env bash
# deploy-site.sh — rsync the built Astro 官网 (web/website/dist/) to the
# pangolin1 VPS web root (/var/www/pangolin-site). Deploy user is root — the
# CI deploy key (secrets.DEPLOY_SSH_KEY) is authorized for root on the host.
# Static files only; nginx/caddy serves them directly, no service restart
# needed. Assumes it is invoked from the repo root, after compile-site.sh has
# produced web/website/dist/.
# deploy-site.sh — 部署构建好的 Astro 官网 (web/website/dist/) 到 Cloudflare Pages。
#
# 官网托管在 CF Pages(项目 pangolin-site,自定义域 pangolin.yanmeiai.com),纯静态、
# 全程 HTTPS、CSP(_headers)自动生效,不落在 VPS 上 —— 故与节点 :443(sing-box)无冲突。
#
# 需环境变量:
# CLOUDFLARE_API_TOKEN 带 Account > Cloudflare Pages > Edit 权限的 CF token
# CLOUDFLARE_ACCOUNT_ID CF 账户 ID
# 由 compile-site.sh 先产出 web/website/dist/;从 repo 根调用。
set -euo pipefail
# shellcheck source=scripts/ci/lib-ssh.sh
. scripts/ci/lib-ssh.sh
# setup_ssh registers the EXIT cleanup trap itself (before writing the key),
# so a mid-setup failure still cleans up — see lib-ssh.sh.
setup_ssh
# Guard against deploying a missing/empty build: `rsync --delete` against an
# empty source would wipe the live site.
if [ ! -d web/website/dist ]; then
echo "==> deploy-site: web/website/dist/ does not exist — refusing to deploy" >&2
echo "==> deploy-site: web/website/dist/ 不存在 — 拒绝部署" >&2
exit 1
fi
if ! find web/website/dist -mindepth 1 -print -quit | grep -q .; then
echo "==> deploy-site: web/website/dist/ is empty — refusing to deploy" >&2
echo "==> deploy-site: web/website/dist/ 为空 — 拒绝部署" >&2
exit 1
fi
DEPLOY_TARGET="root@${DEPLOY_HOST}:/var/www/pangolin-site/"
echo "==> deploy-site: rsync web/website/dist/ -> ${DEPLOY_TARGET}"
rsync -az --delete -e "${RSYNC_SSH}" web/website/dist/ "${DEPLOY_TARGET}"
: "${CLOUDFLARE_API_TOKEN:?deploy-site: CLOUDFLARE_API_TOKEN 未设(需带 Pages:Edit)}"
: "${CLOUDFLARE_ACCOUNT_ID:?deploy-site: CLOUDFLARE_ACCOUNT_ID 未设}"
echo "==> deploy-site: wrangler pages deploy → project pangolin-site (branch main)"
npx --yes wrangler@4 pages deploy web/website/dist \
--project-name=pangolin-site --branch=main --commit-dirty=true
echo "==> deploy-site: done"