name: CI - Build Site
on:
  push:
    branches-ignore:
      - gh-pages
  workflow_dispatch:
  pull_request:
jobs:
  build:
    name: Build Site and Deploy
    runs-on: ubuntu-latest
    steps:
      - uses: actions/setup-node@v3
        with:
          node-version: '12'
      - name: Checkout Repository
        uses: actions/checkout@v3
        with:
          fetch-depth: '0'
          persist-credentials: false
          submodules: 'recursive'
      - name: Install
        run: npm install
        working-directory: 'docs'
      - name: Build
        run: npm run build
        working-directory: 'docs'
      - name: Deploy
        uses: JamesIves/github-pages-deploy-action@3.7.1
        if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main'}}
        with:
          ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
          BRANCH: gh-pages
          FOLDER: docs/.vuepress/dist/
          CLEAN: true
