Schedule icon
Commands icon
Docker icon
If icon
SlackIncomingWebhook icon
Log icon

Report Stale Git Branches Weekly

Find branches with no recent commits and alert Slack so they get cleaned up.

Categories
Infrastructure

Dead branches are where old context goes to be forgotten. This blueprint lists remote branches whose last commit is older than your threshold and posts the list to Slack weekly. Enable the schedule after a first manual run.

How it works

  1. find_stale (io.kestra.plugin.scripts.shell.Commands on the git image) clones with --filter=blob:none, then filters git branch -r by commit date via the ::{"outputs": ...}:: protocol.
  2. stale_found (io.kestra.plugin.core.flow.If) branches to alert_stale or log_clean.
  3. The errors block alerts on clone/scan failure.
  4. Trigger: a disabled weekly Schedule.

What you get

  • The exact stale branch names in Slack.
  • A weekly standing reminder instead of a quarterly cleanup scramble.

Who it's for

  • Repos with many short-lived feature branches.
  • Teams whose "delete merged branches" policy lapsed.

Why orchestrate this with Kestra

git answers "when was this committed"; the flow turns it into a scheduled review loop with alerts and history. The next step (open a cleanup issue, auto-delete via API, tag the owner) is one task away.

Prerequisites

  • Docker available on the Kestra Worker.
  • A Slack webhook.
  • Repo readable from the Worker (public, or credentials in the URL).

Secrets

  • SLACK_WEBHOOK_URL: webhook for stale-list and failure alerts.

Quick start

  1. Add the Slack webhook secret.
  2. Set repo_url and stale_days.
  3. Run once and read stale_branches.
  4. Enable the weekly schedule.

How to extend

  • Auto-delete merged stale branches with the GitHub API.
  • Filter to only merged-into-main branches.
  • Export the list as a CSV artifact.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.