File tree Expand file tree Collapse file tree 1 file changed +53
-0
lines changed
Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Deploy Test Coverage to GitHub Pages
2+
3+ permissions :
4+ contents : write # 允许 GitHub Actions 写入仓库,其中包括创建分支、提交代码等
5+
6+ on :
7+ workflow_dispatch : # 允许手动触发
8+ push :
9+ branches :
10+ - main # 监听 main 分支
11+
12+ jobs :
13+ deploy :
14+ runs-on : ubuntu-latest
15+
16+ steps :
17+ # region: 前端项目构建前置步骤:检出代码、依赖安装、构建(pnpm、nodejs)
18+ - name : Checkout repository
19+ uses : actions/checkout@v4
20+
21+ - name : Setup pnpm
22+ uses : pnpm/action-setup@v4
23+ with :
24+ version : 9 # pnpm 版本,一些pnpm项目带有lockfile的时候,需要版本的匹配,否则可能会报错(pnpm版本不匹配时,会忽略锁文件)
25+ run_install : false
26+
27+ - name : Setup Node.js
28+ uses : actions/setup-node@v4
29+ with :
30+ node-version : 20 # Node.js 版本
31+ # node-version-file: ".nvmrc" # 从 .nvmrc 文件中读取 Node.js 版本,与 node-version 二选一
32+ cache : pnpm # 缓存 pnpm
33+ # endregion
34+
35+ # region: 前端项目构建,根据具体项目情况修改,此处以 <https://github.com/uni-ku/bundle-optimizer> 为例
36+ - name : Install dependencies
37+ run : pnpm install
38+
39+ - name : Run Test
40+ run : pnpm run test:coverage
41+ # endregion
42+
43+ # region: 部署到 GitHub Pages,此处采用 peaceiris/actions-gh-pages@v4
44+ # 该插件可以基于之前的构建流程,通过配置 publish_dir 来指定将要发布的目录
45+ # 之后会将 publish_dir 目录下的文件推送到 gh-pages 分支,当然分支名称也是可以配置的
46+ # 最后需要在 GitHub 仓库的 Settings -> Pages 中设置 gh-pages 分支作为 GitHub Pages 的源
47+ - name : Deploy to GitHub Pages
48+ uses : peaceiris/actions-gh-pages@v4
49+ with :
50+ github_token : ${{ secrets.GITHUB_TOKEN }}
51+ publish_dir : ./coverage # 构建输出目录
52+ publish_branch : coverage # 发布分支,可选,默认为 gh-pages
53+ # endregion
You can’t perform that action at this time.
0 commit comments