# Copyright 2021 Avinal Kumar <avinal.xlvii@gmail.com>
# SPDX-License-Identifier: GPL-2.0 AND LGPL-2.1

name: GitHub Pages Deploy

on:
  push:
    branches:
      - master
  release:
    types:
      - published

jobs:
  build:
    runs-on: ubuntu-20.04

    steps:
      - name: Install Dependencies
        run: |
          sudo apt-get update
          sudo apt-get install --no-install-recommends -y git doxygen graphviz

      - uses: actions/checkout@v2
        with:
          fetch-depth: 50

      - name: Execute docs generation
        run: |
          chmod +x utils/deploy-pages.sh
          bash utils/deploy-pages.sh
        env:
          GH_REPO_REF: ${{ secrets.GH_REPO_REF }}

      - name: Deploy to GitHub Pages
        uses: peaceiris/actions-gh-pages@v3
        with:
          personal_token: ${{ secrets.GH_TOKEN }}
          external_repository: ${{ secrets.GH_REPO_REF }}
          publish_branch: master
          publish_dir: ./code_docs
          force_orphan: true
          user_name: 'github-actions[bot]'
          user_email: 'github-actions[bot]@users.noreply.github.com'
          full_commit_message: ${{ github.event.head_commit.message }}
