# SPDX-FileCopyrightText: (c) TagStudio Contributors
# SPDX-License-Identifier: GPL-3.0-only
---
name: Publish Docs

on:
  push:
    branches:
      - main
    paths:
      - .github/workflows/publish_docs.yaml
      - docs/**
      - mkdocs.yml
      - CHANGELOG.md

permissions:
  contents: write

concurrency:
  group: publish-docs
  cancel-in-progress: true

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repo
        uses: actions/checkout@v4

      - name: Setup Python
        uses: actions/setup-python@v5
        with:
          python-version: "3.12"
          cache: pip

      - name: Install Python dependencies
        run: |
          python -m pip install --upgrade uv
          uv pip install --system .[mkdocs]

      - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV

      - uses: actions/cache@v4
        with:
          key: mkdocs-material-${{ env.cache_id }}
          path: .cache
          restore-keys: |
            mkdocs-material-

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