Skip to content

Commit

Permalink
refactor: 优化部署文档工作流 (#410)
Browse files Browse the repository at this point in the history
  • Loading branch information
Leetfs authored Sep 18, 2024
1 parent bdff7ea commit b0ece49
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 27 deletions.
52 changes: 30 additions & 22 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,42 @@
name: 部署文档
name: 部署到 Cloudflare Pages

on:
push:
branches:
- 'main'
- 'main' # 当推送到 main 分支时触发

jobs:
build:
runs-on: ubuntu-22.04
deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pnpm/action-setup@v3
# 第一步:检出代码
- name: 检出代码
uses: actions/checkout@v3

# 第二步:安装 pnpm
- name: 安装 pnpm
uses: pnpm/action-setup@v3
with:
version: latest
- uses: actions/setup-node@v4
with:
cache: pnpm
- name: Install

# 第三步:安装依赖
- name: 安装依赖
run: pnpm install
- name: Build
run: pnpm build
env:
NODE_OPTIONS: --max_old_space_size=4096
- name: Publish to Cloudflare Pages

# 第四步:构建项目
- name: 构建项目
run: pnpm build # 构建 VitePress 项目

# 第五步:安装 Wrangler
- name: 安装 Wrangler
run: pnpm add -g wrangler@3 # 安装 Wrangler v3

# 第六步:发布到 Cloudflare Pages
- name: 发布到 Cloudflare Pages
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_PAGES_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_PAGES_ACCOUNT }}
projectName: rle-wiki
directory: docs/.vitepress/dist
wranglerVersion: '3'
apiToken: ${{ secrets.CLOUDFLARE_PAGES_TOKEN }} # Cloudflare Pages API Token
accountId: ${{ secrets.CLOUDFLARE_PAGES_ACCOUNT }} # Cloudflare 账户 ID
projectName: rle-wiki # Cloudflare Pages 项目名称
directory: docs/.vitepress/dist # 构建输出目录
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
"vite": "^5.3.1",
"vitepress": "^1.2.3",
"vitepress-sidebar": "^1.23.2",
"vue": "^3.4.30",
"wrangler": "^3.61.0"
"vue": "^3.4.30"
},
"pnpm": {
"overrides": {
Expand Down
3 changes: 0 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b0ece49

Please sign in to comment.