我的方案是这样的:博客使用 <github_name>.github.io 项目作为仓库。src 分支作为 markdown 分支,编辑并保存 markdown 文件后,git push 到远端后。github actions 自动将静态博客生成的 html 文件放入 master 分支。这样过几分钟之后,从域名 https://<github_name>.github.io 看到编辑效果了。
我现在使用 zola (
https://www.getzola.org/) 作为生成工具,简要步骤:
https://jessun2017.github.io/use-zola-blog-generator/如果是 hugo,参考一下这个文件:
```yaml
# This is a basic workflow to help you get started with Actions
name: Hugo on Github Pages
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches: [ src ]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
with:
submodules: true
# Runs a single command using the runners shell
- name: Clean directory ./public/
run: |
rm -rf .git/worktrees/public/
rm -fr ./public/
- name: Setup hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: '0.71.1'
- name: Build
run: |
hugo -b
https://jessun2017.github.io - name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.TOKEN }}
publish_branch: master # default: gh-pages
```