name: Deploy MkDocs

on:
  push:
    branches:
      - main
    paths:
      - 'docs/**'
      - 'mkdocs.yml'
      - 'pyproject.toml'
      - '.github/workflows/docs.yml'
  workflow_dispatch:

permissions:
  contents: write

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      
      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.10'
      
      - name: Install Poetry
        uses: snok/install-poetry@v1
        with:
          version: 1.5.1
          virtualenvs-create: true
          virtualenvs-in-project: true
      
      - name: Install dependencies
        run: |
          poetry install --no-interaction
      
      - name: Ensure directories exist
        run: |
          mkdir -p docs/images
          # Create placeholder images if they don't exist
          [ -f docs/images/logo.png ] || touch docs/images/logo.png
          [ -f docs/images/favicon.png ] || touch docs/images/favicon.png
      
      - name: Deploy docs
        run: |
          poetry run mkdocs gh-deploy --force