Skip to content

Commit 9969b8b

Browse files
🔧 部署文件修改
1 parent d786df0 commit 9969b8b

File tree

1 file changed

+35
-32
lines changed

1 file changed

+35
-32
lines changed

.github/workflows/deploy.yml

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
# 构建 VitePress 站点并将其部署到 GitHub Pages 的示例工作流程
2+
#
13
name: Deploy VitePress site to Pages
24

35
on:
6+
# 在针对 `main` 分支的推送上运行。如果你
7+
# 使用 `master` 分支作为默认分支,请将其更改为 `master`
48
push:
59
branches: [main]
610

@@ -9,7 +13,7 @@ on:
913

1014
# 设置 GITHUB_TOKEN 的权限,以允许部署到 GitHub Pages
1115
permissions:
12-
contents: write
16+
contents: read
1317
pages: write
1418
id-token: write
1519

@@ -20,44 +24,43 @@ concurrency:
2024
cancel-in-progress: false
2125

2226
jobs:
23-
build-and-deploy:
27+
# 构建工作
28+
build:
2429
runs-on: ubuntu-latest
2530
steps:
2631
- name: Checkout
27-
uses: actions/checkout@v3
32+
uses: actions/checkout@v4
2833
with:
29-
fetch-depth: 0
30-
- uses: pnpm/action-setup@v2
31-
with:
32-
version: 8
34+
fetch-depth: 0 # 如果未启用 lastUpdated,则不需要
35+
# - uses: pnpm/action-setup@v3 # 如果使用 pnpm,请取消此区域注释
36+
# with:
37+
# version: 9
38+
# - uses: oven-sh/setup-bun@v1 # 如果使用 Bun,请取消注释
3339
- name: Setup Node
34-
uses: actions/setup-node@v3
40+
uses: actions/setup-node@v4
3541
with:
3642
node-version: 18
37-
cache: pnpm
38-
39-
# 缓存 VitePress 构建产物
40-
- name: Cache VitePress
41-
uses: actions/cache@v3
42-
with:
43-
path: |
44-
docs/.vitepress/cache
45-
docs/.vitepress/.temp
46-
key: vitepress-cache-${{ hashFiles('docs/**/*.md') }}-${{ hashFiles('docs/.vitepress/config.ts') }}
47-
restore-keys: |
48-
vitepress-cache-
49-
43+
cache: npm # 或 pnpm / yarn
5044
- name: Setup Pages
51-
uses: actions/configure-pages@v3
45+
uses: actions/configure-pages@v4
5246
- name: Install dependencies
53-
run: pnpm install
54-
- name: Build
55-
run: |
56-
pnpm run docs:build
57-
touch docs/.vitepress/dist/.nojekyll
58-
- name: Deploy to GitHub Pages
59-
uses: JamesIves/github-pages-deploy-action@v4
47+
run: npm ci # 或 pnpm install / yarn install / bun install
48+
- name: Build with VitePress
49+
run: npm run docs:build # 或 pnpm docs:build / yarn docs:build / bun run docs:build
50+
- name: Upload artifact
51+
uses: actions/upload-pages-artifact@v3
6052
with:
61-
folder: docs/.vitepress/dist
62-
branch: gh-pages
63-
clean: true
53+
path: docs/.vitepress/dist
54+
55+
# 部署工作
56+
deploy:
57+
environment:
58+
name: github-pages
59+
url: ${{ steps.deployment.outputs.page_url }}
60+
needs: build
61+
runs-on: ubuntu-latest
62+
name: Deploy
63+
steps:
64+
- name: Deploy to GitHub Pages
65+
id: deployment
66+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)