11name : Deploy Official Site
22
3+ # 触发条件:1.master分支推送且改动指定文件 2.手动触发(新增核心)
34on :
45 push :
56 branches :
67 - master
78 paths :
89 - ' package/official-site/**'
910 - ' .github/workflows/deploy-docs.yml'
11+ workflow_dispatch : # ✅ 新增:开启手动触发,测试/重部署超方便
1012
13+ # 权限配置:赋予写入仓库内容的权限(自包含,无需仓库额外配置)
1114permissions :
1215 contents : write
1316
@@ -17,27 +20,33 @@ jobs:
1720 steps :
1821 - uses : actions/checkout@v4
1922 with :
20- fetch-depth : 0
23+ fetch-depth : 0 # ✅ 你的配置完全正确:拉取全提交记录,解决VitePress git信息缺失
2124
22- - name : Setup Node
25+ - name : Setup Node.js 20
2326 uses : actions/setup-node@v4
2427 with :
2528 node-version : 20
2629 cache : ' npm'
30+ # ✅ 你的配置完全正确:指定子目录的lock文件,精准缓存依赖
2731 cache-dependency-path : ' package/official-site/package-lock.json'
2832
33+ # ✅ 优化:用working-directory替代cd,配置更整洁
2934 - name : Install Dependencies
30- run : |
31- cd package/official-site
32- npm install
35+ working-directory : ./package/official-site
36+ run : npm install
3337
34- - name : Build
38+ # ✅ 优化:用working-directory替代cd,搭配日志分组
39+ - name : Build VitePress Site
40+ working-directory : ./package/official-site
3541 run : |
36- cd package/official-site
42+ echo "::group::开始构建文档站点"
3743 npm run docs:build
44+ echo "::endgroup::"
3845
46+ # ✅ 修复核心:升级为v4稳定版
3947 - name : Deploy to GitHub Pages
40- uses : peaceiris/actions-gh-pages@v3
48+ uses : peaceiris/actions-gh-pages@v4
4149 with :
4250 github_token : ${{ secrets.GITHUB_TOKEN }}
43- publish_dir : ./package/official-site/.vitepress/dist
51+ # ✅ 你的配置完全正确:VitePress打包产物目录,无需修改
52+ publish_dir : ./package/official-site/.vitepress/dist
0 commit comments