# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Build Docs

on: 
  push:
    branches: [ master ]

jobs:
  docs:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - uses: seanmiddleditch/gha-setup-ninja@master
        
      - name: Set up Python
        uses: actions/setup-python@v1
        with:
          python-version: 3.7
          
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install numpy -I
          pip install pytest torch
          
      - name: Install package
        run: |
          pip install -e .
          
      - name: Install Sphix Dependencies
        run: |
          cd docs/
          pip install -r requirements.txt
          
      - name: Build Sphinx docs
        run: |
          cd docs/
          make html
          touch build/html/.nojekyll
          
      # https://github.com/marketplace/actions/github-pages
      - name: Deploy
        if: success()
        uses: crazy-max/ghaction-github-pages@master
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          build_dir: docs/build/html/
          target_branch: gh-pages
