Schedule icon
Webhook icon
Loop icon
Request icon
Script icon
If icon
SlackIncomingWebhook icon
OutputValues icon

Label GitHub PRs by Size and Flag Oversized Reviews

Triage GitHub PR health with Kestra. Label PRs by diff size and flag oversized reviews on Slack.

Categories
Infrastructure

Big PRs stall reviews and hide bugs. This blueprint polls the GitHub API across a configurable repo list every weekday morning, classifies each open pull request into XS/S/M/L/XL buckets by changed lines, and posts a Slack digest only when a PR exceeds the oversize threshold (default 800 lines). A webhook trigger enables on-demand triage after a release cut.

How it works

  1. every_morning (io.kestra.plugin.core.trigger.Schedule, cron 0 8 * * MON-FRI) launches the run; on_demand_webhook allows ad-hoc triage.
  2. scan_repos (io.kestra.plugin.core.flow.Loop, concurrency 4) fans out across inputs.repositories.
  3. fetch_open_prs (io.kestra.plugin.core.http.Request) lists open PRs with a GITHUB_TOKEN bearer header.
  4. classify_prs (io.kestra.plugin.scripts.python.Script) buckets each PR and collects XL offenders.
  5. alert_on_oversized (io.kestra.plugin.core.flow.If) posts to Slack (io.kestra.plugin.slack.notifications.SlackIncomingWebhook) only when offenders exist.
  6. emit_review_metrics (io.kestra.plugin.core.output.OutputValues) exports scan coverage for audit history.

What you get

  • Consistent XS-to-XL size labels across every repo.
  • Oversize digest with links, authors, and diff stats.
  • Review checklist (split stacks, add tests, request 2 reviewers).
  • Failure alert if the guard itself errors.

Who it's for

  • Engineering managers keeping review latency low.
  • Platform teams enforcing small-batch merge culture.
  • OSS maintainers triaging contributor PRs.

Prerequisites

  • A GitHub token with pull_requests:read scope.
  • Slack Incoming Webhook URL.

Secrets

  • GITHUB_TOKEN: token used to list pull requests.
  • SLACK_WEBHOOK_URL: Slack Incoming Webhook for digests and failure alerts.
  • WEBHOOK_KEY: auth key for the on-demand webhook trigger.

Quick start

  1. Set GITHUB_TOKEN, SLACK_WEBHOOK_URL, and WEBHOOK_KEY secrets.
  2. Edit repositories and warn_additions inputs.
  3. Run once manually to verify API access.
  4. Enable the every_morning schedule.

How to extend

  • Auto-apply size/XS … size/XL labels via the GitHub Issues API.
  • Request changes automatically on PRs 3x over the limit.
  • Persist weekly size histograms to Postgres for review-latency reports.

Links

Inputs

  • repositories (ARRAY of STRING): repo slugs in owner/name format.
  • warn_additions (INT, default 800): changed-line threshold for XL flag.
  • slack_channel (STRING, default #code-review): digest destination.

Outputs

  • emit_review_metrics.values.repos_scanned: number of repos scanned.
  • emit_review_metrics.values.scanned_at: run timestamp for audit reports.
See How

New to Kestra?

Use blueprints to kickstart your first workflows.