Skip to content

Digest

Digest #9

Workflow file for this run

name: Digest
on:
schedule:
# 06:00 UTC daily — summarizes the previous UTC day. On Mondays it also rolls
# up the completed ISO week; on the 1st, the completed calendar month.
- cron: "0 6 * * *"
workflow_dispatch:
inputs:
date:
description: "Date to summarize/anchor (YYYY-MM-DD, UTC). Defaults to yesterday."
required: false
period:
description: "Digest period for manual runs."
required: false
type: choice
options: [daily, weekly, monthly]
default: daily
# Needed to push generated posts. Publishing permissions live on the deploy job.
permissions:
contents: write
# Avoid overlapping runs racing on the same branch.
concurrency:
group: digest
cancel-in-progress: false
jobs:
digest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- name: Generate digest
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENAI_TRIAGE_MODEL: ${{ vars.OPENAI_TRIAGE_MODEL || 'gpt-5.4-nano' }}
OPENAI_WRITE_MODEL: ${{ vars.OPENAI_WRITE_MODEL || 'gpt-5.4-mini' }}
# Lets the digest resolve commit authors to GitHub logins via the API
# (public-repo reads). Without it only noreply-email authors resolve.
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
EVENT: ${{ github.event_name }}
DATE: ${{ github.event.inputs.date }}
PERIOD: ${{ github.event.inputs.period }}
run: |
if [ "$EVENT" = "workflow_dispatch" ] && [ -n "$PERIOD" ] && [ "$PERIOD" != "daily" ]; then
# Manual period rollup (optionally anchored to a date).
if [ -n "$DATE" ]; then
deno task digest --period "$PERIOD" --date "$DATE"
else
deno task digest --period "$PERIOD"
fi
else
# Daily run (optionally for a specific date).
if [ -n "$DATE" ]; then
deno task digest --date "$DATE"
else
deno task digest
fi
# Scheduled rollups over the daily posts just generated: weekly on
# Mondays (completed ISO week), monthly on the 1st (completed month).
if [ "$EVENT" = "schedule" ]; then
if [ "$(date -u +%u)" = "1" ]; then deno task digest --period weekly; fi
if [ "$(date -u +%d)" = "01" ]; then deno task digest --period monthly; fi
fi
fi
- name: Commit new posts
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add src/posts
if git diff --cached --quiet; then
echo "No new posts to commit."
else
git commit -m "digest: add issues for $(date -u +%F)"
git push
fi
# Publish the freshly committed posts. The bot pushes with GITHUB_TOKEN, which
# can't trigger Deploy's `on: push`, so we call the reusable workflow directly.
deploy:
needs: digest
permissions:
contents: read
pages: write
id-token: write
uses: ./.github/workflows/deploy.yml