Report and clean up stale GitHub branches with Slack notifications
Ready for 3.0What this workflow does
This workflow has 14 nodes and runs on a schedule (every week) (plus 1 other trigger). Along the way it connects Slack. It also calls api.github.com over HTTP.
How it runs
Trigger: On a schedule (every week) (plus 1 other trigger).
- Configuration (Edit Fields (Set)): sets 7 fields: repoOwner, scanRepos, staleDays…
- Expand Repo List (Code): runs custom JavaScript code
- Fetch All Branches (HTTP Request): calls api.github.com (POST)
- Fetch Recently Merged PRs (HTTP Request): calls an HTTP API
- Classify Branches — Merged vs Stale (Code): runs custom JavaScript code
- Auto-Delete Enabled? (If): checks a condition and branches into true / false
- Split Branches for Deletion (Code): runs custom JavaScript code
- Format Cleanup Report (Code): runs custom JavaScript code
- Delete Single Branch (HTTP Request): calls an HTTP API (DELETE)
- Send Report to Slack (Slack): uses Slack
…plus 2 more steps. See the full node list below.
Services it uses
HTTP calls to: api.github.com
Before you upgrade to n8n 3.0
Nothing in this workflow is removed in n8n 3.0, so it should import and run after the upgrade.
Nodes used (7)
- Schedule Trigger
n8n-nodes-base.scheduleTrigger - Edit Fields (Set)
n8n-nodes-base.set - Code
n8n-nodes-base.code - HTTP Request
n8n-nodes-base.httpRequest - Slack
n8n-nodes-base.slack - If
n8n-nodes-base.if - Manual Trigger
n8n-nodes-base.manualTrigger
From the author
Quick Overview This workflow runs weekly (or manually) to scan GitHub repositories for merged-but-not-deleted and stale branches, then posts a cleanup report to Slack and can optionally auto-delete a capped number of branches. How it works 1. Runs on a weekly…