name: Publish demo site to Github Pages

on:
  push:
    tags:
      - 'v*.*.*'

jobs:
  publish:
    runs-on: ubuntu-18.04
    timeout-minutes: 30

    steps:
      - uses: actions/checkout@v2

      - name: Install Hugo
        uses: peaceiris/actions-hugo@v2
        with:
          hugo-version: '0.88.1'
          extended: true

      - name: Build demo website to public directory
        run: |
          cd ./exampleSite
          hugo --config ../.github/demo_config.toml --themesDir ../.. --minify

      - name: Deploy to GitHub Pages
        uses: peaceiris/actions-gh-pages@v3
        with:
          personal_token: ${{ secrets.GITHUB_TOKEN }}
          publish_branch: gh-pages
          publish_dir: ./exampleSite/public
          commit_message: 'deploy to GitHub Pages via GitHub Actions'
