name: Publish Docs

on:
  push:
    branches:
      - main

jobs:
  publish-docs:
    runs-on: docs-host

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Render PlantUML diagrams to SVG
        run: |
          mkdir -p docs/images
          rm -f architecture/workspace/*.svg
          docker run --rm \
            -v "$PWD:/work" \
            -w /work \
            ghcr.io/plantuml/plantuml \
            -tsvg architecture/workspace/*.puml
          cp architecture/workspace/*.svg docs/images/

      - name: Build MkDocs site
        run: |
          docker run --rm \
            -v "$PWD:/docs" \
            squidfunk/mkdocs-material:9 \
            build

      - name: Publish site to docs host
        run: |
          rsync -rlDz --delete site/ /opt/kellcreations/docs-platform/published/site/