name: GitHub Pages

on:
  push:
    branches:
      - main-mkdocs

jobs:
  deploy:
    runs-on: ubuntu-22.04
    # Add condition to ensure this only runs on the main repository
    if: github.repository == 'satwareAG/satware.ai'
    permissions:
      contents: write
    concurrency:
      group: ${{ github.workflow }}-${{ github.ref }}
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0 # Added this line for full git history

      - name: Setup Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.13'

      - name: Install MkDocs and plugins
        run: |
          pip install --upgrade pip
          pip install \
            cairosvg \
            libsass \
            mkdocs-exclude \
            mkdocs-git-revision-date-localized-plugin \
            mkdocs-glightbox \
            mkdocs-include-markdown-plugin \
            mkdocs-literate-nav \
            mkdocs-macros-plugin \
            mkdocs-material==9.6.14 \
            "mkdocs-material[imaging]" \
            mkdocs-minify-plugin \
            mkdocs-redirects \
            mkdocs-rss-plugin \
            mkdocs-snippets \
            mkdocs-video \
            watchdog

      - name: Build css
        run: |
          mkdir -p docs/assets/css
          pysassc overrides/assets/css/custom.scss docs/assets/css/custom.css

      - name: Build static site
        run: mkdocs build

      - name: Deploy
        run: mkdocs gh-deploy --force