Files
qqbotsdk/scripts/deploy_docs.sh
T
snowy-yang 35e501aabb feat: Gitea Actions——ruff/pyright 检测与 Cloudflare Pages 文档自动部署
- .gitea/workflows/ci.yml:push(main)/PR/手动触发,setup-uv 装依赖
  后运行与本地一致的 uv run ruff check src tests examples + uv run
  pyright;故意未加 ruff format --check(存量 5 文件格式漂移会打红)
- .gitea/workflows/deploy-docs.yml:main 的文档文件变更时自动部署,
  经 CLOUDFLARE_API_TOKEN/CLOUDFLARE_ACCOUNT_ID secrets 鉴权
- scripts/deploy_docs.sh:组装纯文档 dist/(不含源码,排除
  __pycache__)后 wrangler Direct Upload 上传——CF Pages 的 Git 直连
  只支持 GitHub/GitLab,Gitea 仓库只能走 Direct Upload;新版
  wrangler 的 pages deploy 不再自动建项目,脚本先幂等 create

站点 https://qqbotsdk-docs.pages.dev 已上线。.wrangler/ 缓存与
dist/ 产物入 .gitignore。
2026-09-24 20:18:39 +08:00

27 lines
1.3 KiB
Bash
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.
#!/usr/bin/env bash
# 组装纯文档目录并部署到 Cloudflare Pages(docsify 零构建,Direct Upload)。
#
# 用法:scripts/deploy_docs.sh [项目名] # 项目名默认取 PROJECT_NAME,再默认 qqbotsdk-docs
# 本地首次运行会自动唤起 wrangler 浏览器授权(或预先 export CLOUDFLARE_API_TOKEN);
# 项目不存在时 wrangler 会自动创建,站点地址 https://<项目名>.pages.dev。
# CI(.gitea/workflows/deploy-docs.yml)经 CLOUDFLARE_API_TOKEN/CLOUDFLARE_ACCOUNT_ID 鉴权调用本脚本。
set -euo pipefail
cd "$(dirname "$0")/.."
PROJECT_NAME="${1:-${PROJECT_NAME:-qqbotsdk-docs}}"
rm -rf dist
mkdir dist
# docsify 站点只由这些 markdown 和 index.html 组成,静态资源全部走 CDN——
# 只挑文档文件,不把源码仓库整个传上站点
cp index.html README.md _sidebar.md CHANGELOG.md dist/
cp -r docs examples dist/
cp .nojekyll dist/ 2>/dev/null || true
# examples/ 里的 Python 字节码缓存不该上站点
find dist -type d -name __pycache__ -exec rm -rf {} +
# 新版 wrangler 的 pages deploy 不再自动建项目:先幂等创建(已存在则忽略报错)
npx wrangler pages project create "$PROJECT_NAME" --production-branch=main >/dev/null 2>&1 || true
npx wrangler pages deploy dist --project-name="$PROJECT_NAME" --branch=main --commit-dirty=true