name: Build and deploy docs
on:
  push:
    branches:
      - master
      - docs
permissions:
  contents: read
  pages: write
  id-token: write
jobs:
  docs:
    name: Build and deploy docs
    runs-on: ubuntu-20.04
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Markdown Lint
        run: |
          cd docs
          npx markdownlint-cli  content/

      - name: Build with Hugo
        run: |
          pwd
          curl -sL https://github.com/gohugoio/hugo/releases/download/v0.101.0/hugo_0.101.0_Linux-64bit.tar.gz|tar xzf - hugo
          mv hugo ~/
          ~/hugo --version||true
          cd docs
          test -e public||mkdir public
          ~/hugo --minify
          find public

      - name: Setup Pages
        uses: actions/configure-pages@v1

      - name: Upload artifact
        uses: actions/upload-pages-artifact@v1
        with:
          path: './docs/public'
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@main