Request icon
Loop icon
Log icon
If icon
Comment icon
SlackIncomingWebhook icon

Scan Stale GitHub Pull Requests and Notify Slack

Automate GitHub repository maintenance by scanning stale PRs, adding warning comments, and notifying team channels in Slack.

Categories
Core

Why orchestrate this with Kestra

Managing repository health manually across multiple teams leads to abandoned branches and stale pull requests. Orchestrating stale PR sweeps with Kestra provides declarative scheduling, robust error handling, automated GitHub API authentication, and centralized status notifications without maintaining standalone cron infrastructure or custom scripts.

Prerequisites

  • A target GitHub repository with open pull requests.
  • A GitHub Personal Access Token (PAT) with repo issue write permissions.
  • A Slack Incoming Webhook URL.

Secrets

  • GITHUB_TOKEN: GitHub Personal Access Token used to query pull requests and post comments.
  • SLACK_WEBHOOK_URL: Incoming Webhook URL to send execution summary alerts to Slack.

How it works

  1. Fetches all open pull requests from the specified target repository using the GitHub API.
  2. Loops through each pull request and extracts its metadata (PR number, title, and last updated date).
  3. Compares the PR's updated_at date against the configured days_stale input threshold.
  4. Automatically posts a reminder comment on any PR flagged as stale.
  5. Sends a summary message to Slack detailing total scanned pull requests.

Quick start

  1. Configure the GITHUB_TOKEN and SLACK_WEBHOOK_URL secrets in your Kestra namespace.
  2. Import this blueprint and click Execute with your target repository name.
  3. Verify execution logs and activate the weekly schedule trigger.

How to extend

  • Add an extra branch-closing or auto-labeling task for PRs inactive for over 60 days.
  • Send individual direct messages on Slack to PR authors by mapping GitHub usernames to Slack IDs.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.