name: Documentation
on:
  workflow_dispatch:
  schedule:    
    - cron: "0 0 * * *"

jobs:

  Build-Documentation:
    
    runs-on: self-hosted

    steps:

      
      - name: Checkout gh-pages
        uses: actions/checkout@v1
        with:
          ref: 'gh-pages'

      - name: Checkout branch
        uses: actions/checkout@v1

      - name: Install Triton
        run: |
          alias python='python3'
          cd python
          pip3 install -e .

      - name: Build docs
        run: |
          cd docs
          make html

      - name: Publish docs
        run: |
          git checkout gh-pages
          sh ./update-website.sh
          eval `ssh-agent -s`
          DISPLAY=:0 SSH_ASKPASS=~/.ssh/give_pass.sh ssh-add ${{ secrets.SSH_KEY }} <<< ${{ secrets.SSH_PASS }}
          git remote set-url origin git@github.com:openai/triton.git
          git push