name: Docs

on: [push]

jobs:
  docs:
    runs-on: ubuntu-latest
    if: github.ref == 'refs/heads/main'
    steps:
      - uses: actions/checkout@v3

      - name: Install x11 dependencies for Kludgine
        run: |
          sudo apt-get update -y -qq
          sudo add-apt-repository ppa:oibaf/graphics-drivers -y
          sudo apt-get update
          sudo apt-get install -y \
            libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers

      - uses: dtolnay/rust-toolchain@stable

      - name: Generate Docs
        run: |
          cargo doc --no-deps --all-features --workspace

      - name: Deploy
        uses: khonsulabs/sync-to-dossier@main
        if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/release' || startsWith(github.ref, 'refs/tags/')
        with:
          url: ${{ secrets.DOSSIER_URL }}
          api-key-id: ${{ secrets.DOSSIER_API_KEY_ID }}
          api-key: ${{ secrets.DOSSIER_API_KEY }}
          project: cushy
          from: target/doc/
          to: /${{ github.ref_name }}/docs