---
name: Build GH-Pages
permissions:
  contents: read

on:
  pull_request:
    branches:
      - master
    types:
      - opened
      - synchronize
      - reopened
  push:
    branches:
      - master
  workflow_dispatch:

concurrency:
  group: "${{ github.workflow }}-${{ github.ref }}"
  cancel-in-progress: true

jobs:
  prep:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v5

      - name: Upload artifact
        uses: actions/upload-artifact@v4
        with:
          name: prep
          path: gh-pages-template/
          if-no-files-found: error
          include-hidden-files: true
          retention-days: 1

  call-jekyll-build:
    needs: prep
    uses: LizardByte/LizardByte.github.io/.github/workflows/jekyll-build.yml@master
    secrets:
      GH_BOT_EMAIL: ${{ secrets.GH_BOT_EMAIL }}
      GH_BOT_NAME: ${{ secrets.GH_BOT_NAME }}
      GH_BOT_TOKEN: ${{ secrets.GH_BOT_TOKEN }}
    with:
      clean_gh_pages: true
      site_artifact: 'prep'
      target_branch: 'gh-pages'
