Skip to content

Commit 8a889bf

Browse files
frant1cfrant1c
authored andcommitted
change deploy
1 parent 84e3c67 commit 8a889bf

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

.github/workflows/deploy.yml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Deploy React to GitHub Pages
1+
name: Deploy Vite React to GitHub Pages
22

33
on:
44
push:
@@ -11,20 +11,28 @@ jobs:
1111
- name: Checkout
1212
uses: actions/checkout@v3
1313

14-
- name: Setup Node
14+
- name: Setup Node.js
1515
uses: actions/setup-node@v3
1616
with:
1717
node-version: "18"
1818
cache: "npm"
1919

20-
- name: Install and build
20+
- name: Install dependencies
21+
run: npm install
22+
23+
- name: Build project
24+
run: npm run build
25+
26+
- name: Setup GitHub Pages
2127
run: |
22-
npm install
23-
npm run build
24-
touch build/.nojekyll
28+
# 创建必要的文件
29+
touch dist/.nojekyll
30+
# 如果使用客户端路由,复制 index.html 为 404.html
31+
cp dist/index.html dist/404.html 2>/dev/null || true
2532
26-
- name: Deploy
33+
- name: Deploy to GitHub Pages
2734
uses: peaceiris/actions-gh-pages@v3
2835
with:
2936
github_token: ${{ secrets.GITHUB_TOKEN }}
30-
publish_dir: ./build
37+
publish_dir: ./dist
38+
force_orphan: true # 保持 gh-pages 分支清洁

0 commit comments

Comments
 (0)