方式一:源码部署
参考官方文档:https://hexo.io/zh-cn/docs/github-pages
方式二:一键部署
参考官方文档:https://hexo.io/zh-cn/docs/github-pages
方式三:我的方式
- 将源码传入到 github 私有仓库(因为有部分东西不想对公暴露)
- 利用私有所在仓库 Actions 进行 build
- 再利用 Actions 传入到另一个仓库(jakehu.github.io)
package.json
1 2 3
| "scripts": { "gen": "hexo cl && hexo g" }
|
.github/workflows/deployment.yml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| name: Publish Hexo to gitpage on: push: branches: - master jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Install dependencies run: | npm install -g hexo-cli npm install - name: Generate Hexo site run: | npm run gen - name: Deploy to B repo uses: peaceiris/actions-gh-pages@v3 with: personal_token: ${{ secrets.ACCESS_TOKEN }} external_repository: jakehu/jakehu.github.io PUBLISH_BRANCH: master PUBLISH_DIR: ./public
|
ACCESS_TOKEN 变量需要在源码仓库 Settings->Secrets and variables->Actions
下进行设置