name: Deploy Doxygen documentation to Pages
on:
  push:
    branches: ["master"]
  workflow_dispatch:
concurrency:
  group: "pages"
  cancel-in-progress: false
jobs:
  build:
    runs-on: ubuntu-24.04
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
        with:
          path: openvpn3
      - name: Checkout doxygen-awesome-css
        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
        with:
          path: doxygen-awesome-css
          repository: jothepro/doxygen-awesome-css
          ref: v2.3.4

      - name: Install dependencies
        run: |
          sudo apt update
          sudo apt install -y --no-install-recommends \
            build-essential cmake doxygen graphviz ninja-build \
            libasio-dev libcap-dev liblz4-dev libjsoncpp-dev libssl-dev libxxhash-dev

      - name: Build Doxygen documentation
        id: build
        run: |
          mkdir doxygen
          cd doxygen
          cmake -S ${{ github.workspace}}/openvpn3 -DENABLE_DOXYGEN=ON -DDOXYGEN_HTML_EXTRA_STYLESHEET=${{ github.workspace }}/doxygen-awesome-css/doxygen-awesome.css -GNinja
          ninja -v doxygen-core
          touch doxygen/core/html/.nojekyll
      - name: Upload static files as artifact
        id: deployment
        uses: actions/upload-pages-artifact@v3.0.1
        with:
          path: doxygen/doxygen/core/html/

  deploy:
    needs: build
    permissions:
      pages: write      # to deploy to Pages
      id-token: write   # to verify the deployment originates from an appropriate source
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    runs-on: ubuntu-24.04
    steps:
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v4.0.5
