name: website

on:
  push:
    branches:
      - main

permissions:
  contents: read

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v4
        with:
          python-version: '3.11'

      - run: python -m pip install --upgrade pip
      - run: pip install .
      - run: pip install pdoc
      - run: pdoc --docformat google --output-dir docs yotpy
        env:
          PYTHONPATH: ${{ github.workspace }}/..

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

  deploy:
    needs: build
    runs-on: ubuntu-latest
    permissions:
      pages: write
      id-token: write
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    steps:
      - id: deployment
        uses: actions/deploy-pages@v2
