-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Vitepress config to use new Cloudflare API token and account ID
- Loading branch information
Showing
1 changed file
with
20 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,43 @@ | ||
name: 部署到Cloudflare Pages | ||
name: 部署到 Cloudflare Pages | ||
|
||
# 当推送到 main 分支时触发 | ||
on: | ||
push: | ||
branches: | ||
- 'main' # 监听 main 分支的推送 | ||
- 'main' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-22.04 # 选择 Ubuntu 22.04 作为运行环境 | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# 第一步:检出代码 | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # 完整检出代码历史 | ||
- name: 检出代码 | ||
uses: actions/checkout@v3 | ||
|
||
# 第二步:安装 pnpm | ||
- uses: pnpm/action-setup@v3 | ||
- name: 安装 pnpm | ||
uses: pnpm/action-setup@v3 | ||
with: | ||
version: latest # 安装最新版本的 pnpm | ||
|
||
# 第三步:设置 Node.js 环境并启用 pnpm 缓存 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
cache: pnpm # 启用 pnpm 缓存,加快依赖安装速度 | ||
|
||
# 第四步:安装依赖 | ||
# 第三步:安装依赖 | ||
- name: 安装依赖 | ||
run: pnpm install # 使用 pnpm 安装依赖 | ||
|
||
# 第五步:构建项目 | ||
# 第四步:构建项目 | ||
- name: 构建项目 | ||
run: pnpm build # 构建 VitePress 文档 | ||
env: | ||
NODE_OPTIONS: --max_old_space_size=4096 # 增加 Node.js 内存限制 | ||
run: pnpm run docs:build # 构建 VitePress 项目 | ||
|
||
# 第五步:检查构建输出目录 | ||
- name: 检查构建输出 | ||
run: ls -alh docs/.vitepress/dist # 列出构建后的文件,确保生成正确 | ||
|
||
# 第六步:发布到 Cloudflare Pages | ||
- name: 发布到 Cloudflare Pages | ||
uses: cloudflare/pages-action@v1 | ||
with: | ||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} # 在 GitHub Secrets 中配置你的 Cloudflare API Token | ||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} # 在 GitHub Secrets 中配置你的 Cloudflare Account ID | ||
projectName: study-wiki # Cloudflare Pages 项目名称 | ||
directory: docs/.vitepress/dist # 替换为 VitePress 构建输出的目录 | ||
apiToken: ${{ secrets.CLOUDFLARE_PAGES_TOKEN }} # Cloudflare Pages API Token | ||
accountId: ${{ secrets.CLOUDFLARE_PAGES_ACCOUNT }} # Cloudflare 账户 ID | ||
projectName: study-wiki # 替换为你的 Cloudflare Pages 项目名称 | ||
directory: docs/.vitepress/dist # 确保这是构建后的输出目录 |