Hugo With Github Actions
簡單記錄一下
我是採用不同兩個repo的方式
一個repo放整份code
另一份則是單純hugo輸出的靜態網頁, 並放在前一份repo的public底下作為submodule
name: github-pages-deploy
on:
push:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
with:
submodules: true
fetch-depth: 0
- name: checkout
uses: actions/checkout@v2
with:
repository: your_username/your_username.github.io
# 需要先去個人的Settings->Developer settings->Personal access tokens申請,
# 然後再到這個專案的Settings->Secrets新增
token: ${{ secrets.DEPLOY_TO_GITHUB_PAGE_TOKEN }}
path: public
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: 'latest'
extended: true
- name: Build
run: hugo --minify
- name: deploy and publish updates
working-directory: ./public
run: |
git config --local user.email $USER_EMAIL
git config --local user.name $USER_NAME
git add .
git commit -m "autocommit"
git push https://$USER_NAME:$REPO_KEY@github.com/$USER_NAME/$USER_NAME.github.io.git master
env:
REPO_KEY: ${{ secrets.DEPLOY_TO_GITHUB_PAGE_TOKEN }}
USER_NAME: your_username
USER_EMAIL: your_email