name: GitHub Pages

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3 #Setup Node
        with:
          node-version-file: '.nvmrc'
          cache: 'npm'
      - run: npm ci
      - run: make build
      - run: make examples
      - name: Upload Pages artifact
        uses: actions/upload-pages-artifact@v2
        with:
          path: ./examples

  deploy:
    needs: build
    permissions:
      pages: write      # to deploy to Pages
      id-token: write
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}

    runs-on: ubuntu-latest
    steps:
        - name: Deploy to GitHub Pages
          id: deployment
          uses: actions/deploy-pages@v2
