利用Github action,实现修改网站源代码后,自动执行生成静态页面+部署改变到github pages的操作(无后端静态页面) 代码如下:
| name: Hexo Deploy Automatically | |
|---|---|
| on: | |
| push: | |
| branches: | |
| - hexo # 网站源码所在分支名称 | |
| pull_request: | |
| branches: | |
| - hexo # 网站源码所在分支名称 | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| node-version: [16.x] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v2 | |
| - name: Use Node.js $NaN | |
| uses: actions/setup-node@v1 | |
| with: | |
| node-version: $NaN | |
| - name: Generate | |
| run: | | |
| npm i && npx hexo g | |
| - name: Deploy | |
| uses: peaceiris/actions-gh-pages@v3 | |
| with: | |
| github_token: $ | |
| publish_branch: main # 静态页面代码(即部署在Github Pages上的代码)所在分支名称 | |
| publish_dir: ./public | |
| force_orphan: true |
- 本文链接:https://whocansee.github.io/2022/08/22/autopush/
- 版权声明:本博客所有文章除特别声明外,均默认采用 许可协议。