name: Publish docs

on:
  push:
    tags:
      - 'OFDLV*'
    paths:
      - 'docs/**'
      - '.gitea/workflows/publish-docs.yml'
  workflow_dispatch:

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.10'

      - name: Install MkDocs
        run: |
          pip install mkdocs

      - name: Build site
        run: |
          mkdocs build --clean

      - name: Deploy site
        run: |
          sudo rm -rf /var/www/mkdocs/*
          sudo cp -r site/* /var/www/mkdocs/
          sudo chown -R www-data:www-data /var/www/mkdocs/