# This is a basic workflow to help you get started with Actions

name: DOC

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:
    name: Build doc
    runs-on: ubuntu-latest
    steps:

    - name: workaround bug
      run: sudo apt-get update

    - name: checkout
      uses: actions/checkout@v2

    - name: setup ocaml
      uses: avsm/setup-ocaml@v1
      with:
        ocaml-version: 4.14.2

    - name: install deps
      run: |
        export OPAMYES=true
        opam repo add coq https://coq.inria.fr/opam/released
        opam repo add coq-dev https://coq.inria.fr/opam/core-dev
        opam repo add extra-dev https://coq.inria.fr/opam/extra-dev
        opam update
        opam install coq-serapi.8.20.0+0.20.0 ./coq-elpi.opam coq-core.8.20.0
        sudo apt-get update
        sudo apt-get install python3-pip -y
        pip3 install git+https://github.com/cpitclaudel/alectryon.git@c8ab1ec

    - name: build doc
      run: opam exec -- make doc COQ_ELPI_ALREADY_INSTALLED=1

    - name: Save artifact
      uses: actions/upload-artifact@v3
      with:
        path: doc

    - name: deploy
      uses: JamesIves/github-pages-deploy-action@4.1.4
      if: ${{ github.ref == 'refs/heads/master' }}
      with:
        branch: gh-pages
        folder: doc
