name: GitHub Pages site + Doxygen API

on:
  release:
    # Trigger when a release object is created and when it's published.
    # Some GitHub flows create a release object then publish it later; include both.
    types: [created, published]
  # Also trigger on tag creation pushes so releasing via Git tags still runs the workflow
  push:
    tags:
      - "v*"  # common release tag pattern like v1.2.3
    branches:
      - master
  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

permissions:
  contents: write
  pages: write
  id-token: write

jobs:
  deploy:
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - name: Install Doxygen
        run: sudo apt-get install doxygen graphviz python3 -y
      - name: Generate Doxygen Documentation
        run: ./doxygen.py
      - name: Assemble Pages site
        run: |
          # Landing page lives at /
          # Doxygen API reference lives at /api/
          mkdir -p _site
          cp -r site/. _site/
          mkdir -p _site/api
          cp -r doc/api/html/. _site/api/
          # Make sure the static landing page wins at the root.
          ls -la _site
          ls -la _site/api | head
      - name: Deploy to GitHub Pages
        id: deployment
        uses: peaceiris/actions-gh-pages@v3
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: _site
