.github/workflows/beat.yml

name: Beat

# step one of the daily beat (AGENTS.md ยง The daily beat): the digest of the UTC day that just ended,
# committed to the branch `digests` as YYYY-MM-DD.md. the writer reads it from there.
# the schedule asks every hour because GitHub drops scheduled runs (on 2026-11-18 the 00:07 run never fired);
# a scheduled run leaves at once when the day's digest is already on the branch, so one digest a day is written.
on:
  schedule:
    - cron: '7 * * * *'
  workflow_dispatch:
    inputs:
      day:
        description: 'UTC day to collect, YYYY-MM-DD (empty: yesterday)'
        required: false

permissions:
  contents: write

jobs:
  collect:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Name the day
        id: day
        env:
          DAY: ${{ inputs.day }}
        run: |
          if [ -z "$DAY" ]; then
            DAY="$(date -u -d yesterday +%F)"
            if git fetch -q origin digests && git cat-file -e "FETCH_HEAD:$DAY.md" 2>/dev/null; then
              echo "the digest of $DAY is on the branch"; echo "done=true" >> "$GITHUB_OUTPUT"
            fi
          fi
          echo "DAY=$DAY" >> "$GITHUB_ENV"

      - name: Collect the digest
        if: steps.day.outputs.done != 'true'
        env:
          GH_TOKEN: ${{ github.token }}
        run: python3 scripts/beat_collect.py --day "$DAY" --out "$RUNNER_TEMP/digest"

      - name: Commit it to the digests branch
        if: steps.day.outputs.done != 'true'
        run: |
          git config user.name "github-actions[bot]"
          git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
          if git fetch -q origin digests; then
            git checkout -q -B digests FETCH_HEAD
          else
            git checkout -q --orphan digests
            git rm -rfq .
          fi
          cp "$RUNNER_TEMP/digest/$DAY.md" "$DAY.md"
          git add "$DAY.md"
          if git diff --cached --quiet; then echo "the digest of $DAY is unchanged"; exit 0; fi
          git commit -qm "digest: $DAY"
          git push -q origin digests

Graph