name: deploy-docs

on:
  push:
    branches:
      - main
    paths:
    - 'docs/**'

permissions:
  contents: write

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

    - name: Setup Python
      uses: actions/setup-python@v4
      with:
        python-version: 3.x

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

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

    - name: Pip install
      run: pip install mkdocs-material

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