name: Write blog post

on:
  schedule:
    - cron: "0 6 * * 1,3,5"  # Mon/Wed/Fri 6am UTC
  workflow_dispatch:

permissions:
  contents: write

concurrency:
  group: blog-content
  cancel-in-progress: false

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

      - uses: actions/setup-python@v5
        with:
          python-version: "3.11"

      - name: Install dependencies
        run: pip install -r blog/scripts/requirements.txt

      - name: Generate and publish post
        env:
          ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: python blog/scripts/write-post.py
