利用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