name: Build Org Website

on:
  push:
    branches:
      - main

  schedule:
    - cron: "0 0 * * *"

  workflow_dispatch:

jobs:
  build:
    runs-on: org-web
    env:
      SITE_OUTPUT_DIR: /home/zaine/master-folder/org_files/org_web/output

    steps:
      - name: Check out repo
        uses: actions/checkout@v4

      - name: Build site
        run: |
          mkdir -p /home/zaine/logs
          SITE_CLEAN=1 make 2>&1 | tee /home/zaine/logs/org-web.log

      - name: Monitor build and notify Discord
        if: always()
        env:
          DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
          API_KEY: ${{ secrets.API_KEY }}
        run: /snap/bin/pwsh -NoProfile -File ./gitea-build-monitor.ps1
