Commands icon
If icon
SlackIncomingWebhook icon
Schedule icon

GitHub Repository Stale Branch Lifecycle and Hygiene Sentinel

Audits GitHub repository branches to detect abandoned, unmerged branch sprawl and enforce git repository lifecycle hygiene.

Categories
BusinessCloud

How it works

This workflow connects to the GitHub REST API (/repos/{owner}/{repo}/branches) to audit all active git branches. It excludes default trunk branches (main, master, develop) and evaluates the total volume of feature, hotfix, and experiment branches. When developers abandon merged PRs without enabling automatic branch deletion, branches accumulate over time. When branch sprawl exceeds the threshold, an automated Slack reminder is sent to engineering leads.

What you get

  • Proactive repository hygiene enforcement.
  • Prevents git metadata bloat and confusing branch auto-completions in IDEs.
  • Sample inventory of candidate branches for cleanup.

Who it's for

  • Engineering Managers and Lead Developers maintaining clean codebase standards.
  • DevOps Engineers automating repository maintenance across organization fleets.

Why orchestrate this with Kestra

  • Scheduled Weekly Sweeps: Run non-intrusive hygiene checks every Monday morning.
  • Multi-Repo Fleet Audits: Easily loop over dozens of corporate microservice repositories.
  • Safe Notifications: Dispatch friendly reminders before initiating automatic branch archiving.

Prerequisites

  • GitHub token with repo or public_repo permissions.
  • Secrets GITHUB_TOKEN and SLACK_WEBHOOK configured in Kestra.

Quick start

  1. Import this blueprint into Kestra.
  2. Set target organization and repository name.
  3. Run the workflow to inspect current branch counts.

How to extend

  • Query the last commit date for each branch to filter specifically for branches older than 60 days.
  • Automatically delete branches that have already been merged into default branch.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.