name: "Publish GitHub Pages"

on:
  push:
    branches:
    - master
  workflow_dispatch:

concurrency:
  group: "pages"
  cancel-in-progress: true

jobs:
  deploy:
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
    - name: Checkout
      uses: actions/checkout@v4
    - name: Install packages
      run: sudo apt-get install doxygen tcl
    - name: Get docgen
      run: wget https://github.com/nishistack/docgen/raw/refs/heads/master/docgen -O docgen && chmod +x docgen
    - name: Create directory
      run: mkdir -p build
    - name: Build main page
      run: ./docgen
    - name: Build engine document
      run: cd engine && doxygen && mv doc/html ../build/engine
    - name: Deploy
      uses: JamesIves/github-pages-deploy-action@v4
      with:
        token: ${{ secrets.GITHUB_TOKEN }}
        branch: gh-pages
        folder: build
