name: "Build Documentation"

on:
  push:
    branches: [main, stable, oldstable]

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  generate-doc-and-upload-coverage:
    name: Build XML documentation and upload coverage
    runs-on: ubuntu-latest
    container: greenbone/doxygen
    steps:
      - name: Run the c lang coverage action
        uses: greenbone/actions/doc-coverage-clang@v3
        with:
          token: ${{ secrets.CODECOV_TOKEN }}

  build-gmp-doc:
    name: Build GMP documentation
    runs-on: ubuntu-latest
    container: ${{ vars.SELF_HOSTED_REGISTRY || 'registry.community.greenbone.net' }}/community/gvm-libs:stable
    steps:
      - name: Check out gvmd
        uses: actions/checkout@v6
      - name: Generate GMP documentation (HTML)
        run: |
          mkdir build
          cd build
          cmake -DSKIP_SRC=1 ..
          make doc-gmp
      - name: Upload GMP documentation artifact
        uses: actions/upload-artifact@v6
        with:
          name: gmp.html
          path: build/doc/gmp.html
          retention-days: 14
