Github Actions Website Pipeline

main.yaml

name: CI

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v2
      
      - name: Run ShellCheck
        uses: ludeeus/action-shellcheck@master
        with:
          scandir: '$GITHUB_WORKSPACE/scripts'
          
      - name: Make temp directory
        id: dir
        run: |
          dir=$(mktemp -d)
          echo ::set-output name=dir::"$dir"

      - name: build html from markdown
        run: |
          "$GITHUB_WORKSPACE"/scripts/build.sh "${{ steps.dir.outputs.dir }}"
        
      - uses: actions/checkout@v2
        with:
          ref: gh-pages
          
      - name: populate gh-pages branch
        run: |
          cp -rTp "${{ steps.dir.outputs.dir }}" "$GITHUB_WORKSPACE"
          rm -r "${{ steps.dir.outputs.dir }}"
          
      - name: Commit & Push changes
        uses: actions-js/push@master
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          message: "Publish website"
          branch: gh-pages