name: Static Site CI
on:
  schedule:
    - cron: "0 1 * * *"
  repository_dispatch:
    types: [static_site]
  workflow_dispatch:
  push:
    branches:
      - main
    paths:
      - ".upptimerc.yml"
      - "README.md"
      - "history/**"

jobs:
  release:
    name: Build and deploy status site
    runs-on: ubuntu-latest
    if: "!contains(github.event.head_commit.message, '[skip ci]')"
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          ref: ${{ github.head_ref }}
          token: ${{ secrets.GH_PAT || github.token }}
      - name: Generate site
        uses: upptime/uptime-monitor@v1.41.0
        with:
          command: "site"
        env:
          GH_PAT: ${{ secrets.GH_PAT || github.token }}
      - name: Deploy to gh-pages branch
        uses: peaceiris/actions-gh-pages@v4
        with:
          github_token: ${{ secrets.GH_PAT || github.token }}
          publish_dir: "site/status-page/__sapper__/export/"
          force_orphan: "false"
          user_name: "Upptime Bot"
          user_email: "73812536+upptime-bot@users.noreply.github.com"

permissions:
  contents: write
