name: Build
on: [push]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@v4
    - name: Install packages
      run: sudo apt-get -y install ocaml-nox libyojson-ocaml-dev dune ocaml-odoc
    - name: Build
      run: dune build
    - name: Test
      run: |
        sudo apt-get -y install pandoc
        make -C examples test
    - name: Generate documentation
      run: make doc
    - name: Upload website artifact
      uses: actions/upload-pages-artifact@v2
      with:
        path: ./_build/default/_doc/_html
  deploy:
    needs: build
    permissions:
      pages: write
      id-token: write
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    runs-on: ubuntu-latest
    steps:
      - name: Deploy website
        id: deployment
        uses: actions/deploy-pages@v2
