name: Docs
on:
  workflow_dispatch:
  push:
    paths:  # rebuild the docs when the version changes or the docs change
      - docs/*
      - Project.toml
  pull_request:  # run when pull requests are made
    paths:
      - docs/*
      - Project.toml
jobs:
  docs:
    name: Documentation
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: julia-actions/setup-julia@latest
        with:
          version: '1.12'
      - name: Install dependencies
        run: |
          sudo apt install libxt6 libxrender1 libxext6 libqt5widgets5
      - name: Instantiate
        env:
          PYTHON: ""
        run: |
          julia --project=docs -e '
            using Pkg
            Pkg.instantiate()
            Pkg.develop(PackageSpec(path=pwd()))
            Pkg.instantiate()'
      - name: Build and deploy
        env:
          PYTHON: ""
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
          CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
        run: julia --project=docs docs/make.jl
      - uses: julia-actions/julia-processcoverage@v1
      - uses: codecov/codecov-action@v1