name: Build documentation
on:
  push:
    branches:
      - main
  workflow_dispatch: 

permissions:
  contents: read
  pages: write
  id-token: write

concurrency:
  group: "pages"
  cancel-in-progress: true
  
jobs:
  build-docs:
    name: build-docs
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/setup-node@v3
        with:
          node-version: 18
      - uses: actions/checkout@v3 # check out this repo

      - name: Build docs
        run: |
          cd docs
          npm install
          npm run build

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

      - name: Upload artifact
        uses: actions/upload-pages-artifact@v1
        with:
          path: docs/build

      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v1