name: Meson Build and Deploy

on:
  push:
    branches: ["lisp"]
  pull_request:

jobs:
  build:
    runs-on: home-1

    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        with:
          tokens: ${{ secrets.GITEA_TOKEN }}

      - name: Install dependencies
        run: |
          sudo apt-get update
          sudo apt-get install -y meson ninja-build gcc

      - name: Configure Meson
        run: meson setup build

      - name: Build project
        run: meson compile -C build

      - name: Run tests
        run: meson test -C build --print-errorlogs || true

      - name: Upload artifact
        uses: actions/upload-artifact@v4
        with:
          name: beluga
          path: build/

      - name: Install Doxygen
        run: sudo apt-get update && sudo apt-get install -y doxygen graphviz

      - name: Build Doxygen Docs
        run: doxygen Doxyfile

      - name: Deploy to Pages
        uses: peaceiris/actions-gh-pages@v3
        with:
          publish_dir: ./docs/html
          publish_branch: pages
          github_token: ${{ secrets.GITEA_TOKEN }}
