name: mkdocs-material
on:
  push:
    branches:
      - 'refs/heads/main'

permissions:
    contents: write

jobs:
  mkdocs-material:
    if: github.event.pull_request.draft == false
    runs-on: ubuntu-latest
    env:
      REPO_URL: '${{ github.server_url }}/${{ github.repository }}'
      REPO_NAME: '${{ github.repository }}'
      SITE_URL: 'https://${{ github.repository_owner }}.github.io/InvokeAI'
    steps:
      - name: checkout sources
        uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: setup python
        uses: actions/setup-python@v4
        with:
          python-version: '3.10'
          cache: pip
          cache-dependency-path: pyproject.toml

      - name: install requirements
        env:
          PIP_USE_PEP517: 1
        run: |
          python -m \
            pip install ".[docs]"

      - name: confirm buildability
        run: |
          python -m \
            mkdocs build \
            --clean \
            --verbose

      - name: deploy to gh-pages
        if: ${{ github.ref == 'refs/heads/main' }}
        run: |
          python -m \
            mkdocs gh-deploy \
            --clean \
            --force