Skip to content

Commit 92d0641

Browse files
committed
chore: 使用pnpm作为包管理器并推送到单独分支
1 parent a97b848 commit 92d0641

File tree

1 file changed

+21
-47
lines changed

1 file changed

+21
-47
lines changed

.github/workflows/deploy.yml

Lines changed: 21 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,43 @@
1-
# 构建并部署到 GitHub Pages
21
name: Deploy to GitHub Pages
32

43
on:
5-
# 当推送到 main 分支时触发
64
push:
7-
8-
# 允许手动触发工作流
5+
branches:
6+
- master
97
workflow_dispatch:
108

11-
# 设置 GITHUB_TOKEN 权限,允许部署到 GitHub Pages
129
permissions:
13-
contents: read
14-
pages: write
15-
id-token: write
16-
17-
# 只允许同时运行一个部署,跳过正在运行和最新队列之间的运行队列
18-
# 但是,不要取消正在进行的运行,因为我们希望让这些生产部署完成
19-
concurrency:
20-
group: "pages"
21-
cancel-in-progress: false
10+
contents: write
2211

2312
jobs:
24-
# 构建作业
25-
build:
13+
build-and-deploy:
2614
runs-on: ubuntu-latest
2715
steps:
2816
- name: Checkout
2917
uses: actions/checkout@v4
3018

31-
- name: Setup Node.js
32-
uses: actions/setup-node@v4
19+
- name: Setup pnpm
20+
uses: pnpm/action-setup@v4
3321
with:
34-
node-version: '20'
35-
cache: 'npm'
22+
version: 10
23+
run_install: false
3624

37-
- name: Setup Pages
38-
uses: actions/configure-pages@v4
25+
- name: Setup Node
26+
uses: actions/setup-node@v4
3927
with:
40-
# 自动注入正确的基础 URL
41-
static_site_generator: custom
28+
node-version: 20
29+
cache: pnpm
30+
cache-dependency-path: pnpm-lock.yaml
4231

4332
- name: Install dependencies
44-
run: |
45-
npm ci
33+
run: pnpm install --frozen-lockfile
4634

47-
- name: Build with Vite
48-
run: |
49-
npm run build
50-
env:
51-
NODE_ENV: production
52-
CI: true
35+
- name: Build site
36+
run: pnpm run build
5337

54-
- name: Upload artifact
55-
uses: actions/upload-pages-artifact@v3
38+
- name: Deploy to gh-pages
39+
uses: JamesIves/github-pages-deploy-action@v4
5640
with:
57-
path: ./dist
58-
59-
# 部署作业
60-
deploy:
61-
environment:
62-
name: github-pages
63-
url: ${{ steps.deployment.outputs.page_url }}
64-
runs-on: ubuntu-latest
65-
needs: build
66-
steps:
67-
- name: Deploy to GitHub Pages
68-
id: deployment
69-
uses: actions/deploy-pages@v4
41+
branch: gh-pages
42+
folder: dist
43+
token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)