name: Build and deploy internal HTML documentation

permissions:
  contents: write

on:
  push:
    branches:
      - master

jobs:
  html-documentation:
    concurrency: ci-${{ github.ref }}
    strategy:
      fail-fast: true
      matrix:
        ocaml-compiler:
          - 4.14.x
        os:
          - ubuntu-latest

    runs-on: ${{ matrix.os }}
    steps:
      - uses: fkirc/skip-duplicate-actions@master

      - name: Checkout code
        uses: actions/checkout@v4

      - name: Use OCaml ${{ matrix.ocaml-compiler }}
        uses: ocaml/setup-ocaml@v2
        with:
          ocaml-compiler: ${{ matrix.ocaml-compiler }}
          dune-cache: true

      - name: Install dependencies
        run: opam install --locked --deps-only --with-test --with-doc ./beluga.opam

      - name: Build HTML documentation
        run: opam exec -- dune build @doc

      - name: Deploy HTML documentation
        uses: JamesIves/github-pages-deploy-action@v4
        with:
          folder: _build/default/_doc/_html
