Blogging with gh-pages and and Github Actions

In order to host my blog I looked no further then gh-pages. Since my sourcecode is on github and they offer free gh-pages and ci with github actions I see no reason why this simple blog should be hosted anywhere else.

The github workflow is pretty simple

On any push to master it will

  • fetch the site with submodules (to get the theme)
  • generate png file from all the puml files in /static
  • setup hugo version 0.82
  • generate minified version
  • publish to gh-pages branch

Note that in order to get it to work with a custom domain you need a CNAME file in static.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
name: github pages

on:
  push:
    branches:
      - main  # Set a branch to deploy

jobs:
  deploy:
    runs-on: ubuntu-18.04
    steps:
      - uses: actions/checkout@v2
        with:
          submodules: true  # Fetch Hugo themes (true OR recursive)
          fetch-depth: 0    # Fetch all history for .GitInfo and .Lastmod
      - name: Generate PNG Diagrams
        uses: cloudbees/plantuml-github-action@master
        with:
            args: -v -tpng static/*.puml
      - name: Setup Hugo
        uses: peaceiris/actions-hugo@v2
        with:
          hugo-version: '0.82.0'
      - name: Build
        run: hugo --minify
      - name: Deploy
        uses: peaceiris/actions-gh-pages@v3
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./public