name: Deploy docs
on:
  push:
    branches:
      - main
concurrency:
  group: ${{ github.workflow }}
  cancel-in-progress: true
jobs:
 docs:
    # Create latest docs
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          token: ${{ secrets.SGILE_PAT }}
          submodules: recursive
          fetch-depth: 0 # fetch all commits/branches
      - name: Set up Conda
        uses: conda-incubator/setup-miniconda@v3
        with:
          python-version: "3.10"
          miniforge-version: latest
          conda-remove-defaults: true
      - name: Install libsndfile
        run: |
          sudo apt-get update
          sudo apt-get install -y libsndfile1
      - name: Install dependencies and package
        run: |
          pip install --upgrade pip
          CUDA_TAG=cpu pip install -r requirements.torch.txt --find-links https://download.pytorch.org/whl/torch_stable.html
          pip install cython
          pip install -e .
      - name: Install documentation dependencies
        run: |
          pip install -r docs/requirements.txt
      - name: Setup doc deploy
        run: |
          git config user.name 'github-actions[bot]'
          git config user.email 'github-actions[bot]@users.noreply.github.com'
      - name: Deploy docs with mike 🚀
        run: |
          mike deploy --push --update-aliases dev latest
