Skip to content

Post last X hours of commits to Discord (cron) #11763

Post last X hours of commits to Discord (cron)

Post last X hours of commits to Discord (cron) #11763

# .github/workflows/commits-to-discord-cron.yml
name: Post last X hours of commits to Discord (cron)
on:
schedule:
- cron: "*/5 * * * *" # every 5 minutes (UTC); fastest reliable cadence
workflow_dispatch:
inputs:
hours_back:
description: "Look back this many hours"
required: false
default: "0.25" # ~15 minutes when run manually
branch:
description: "Branch to scan"
required: false
default: "main"
jobs:
poll:
runs-on: ubuntu-latest
permissions:
contents: read
env:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- run: pip install requests openai
- name: Post digest to Discord
run: |
# On schedule, github.event.inputs.* are empty, so these defaults apply:
HOURS_BACK=${{ github.event.inputs.hours_back || '0.25' }} # ~15 min by default
BRANCH=${{ github.event.inputs.branch || 'main' }}
echo "Running at $(date -u) UTC; hours=$HOURS_BACK; branch=$BRANCH"
python .github/scripts/poll_commits.py --hours "$HOURS_BACK" --branch "$BRANCH"