File tree Expand file tree Collapse file tree 1 file changed +16
-8
lines changed
Expand file tree Collapse file tree 1 file changed +16
-8
lines changed Original file line number Diff line number Diff line change 1- name : Deploy React to GitHub Pages
1+ name : Deploy Vite React to GitHub Pages
22
33on :
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 分支清洁
You can’t perform that action at this time.
0 commit comments