I still had to run the ./deploy.sh
script after committing changes. Not anymore - I’m calling this script in a github action being run after a push to master
!
Some refactoring was required - I moved the command related to pushing the generating site to a separate script, and this script is called from github actions.
UPDATE: this did not work at all! I resorted to trying out a lot of push Github Actions but none worked. Then I stumbled on this specific ‘Deploy to GH Pages’ action and this one did the trick. Only downside now is the commit message - every commit message is suffixed with the name of my hugo repo and the commit hash.
Below is the complete action. Enjoy!
name: Build and Deploy
on:
push:
branches: [master]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: setup git submodules
run: |
git submodule init
git submodule update
- name: setup hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: '0.75.1'
- name: build hugo website
run: hugo --minify
- name: dump information
env:
TO_DUMP: ${{ toJson(github.event) }}
run: echo "$TO_DUMP"
- name: deploy to github Pages
uses: peaceiris/actions-gh-pages@v3
with:
publish_dir: ./pieterjd.github.io
external_repository: pieterjd/pieterjd.github.io
publish_branch: master
personal_token: ${{ secrets.GH_PAGES_ACCESS_TOKEN }}
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
full_commit_message: ${{ github.event.head_commit.message }}