Project

General

Profile

Actions

Feature #33

closed
CD

Enable automatic branch deletion after PR merges for all repositories

Feature #33: Enable automatic branch deletion after PR merges for all repositories

Added by Client Dashboard about 2 months ago. Updated about 2 months ago.

Status:
Shipped
Priority:
Normal
Assignee:
-
Start date:
06/11/2026
Due date:
% Done:

0%

Estimated time:
spec_ref:

conversation:26

build_status:
build_number:
ci_run_url:
scan_status:
scan_report_url:
deploy_status:
preprod_url:
deployed_at:
branch:
pr_url:
security_key:
severity:
paused:

Description

### Problem
Currently, when a pull request (PR) is merged in any repository, the associated branch remains in the repository. This leads to clutter and requires manual cleanup, which is inefficient and error-prone.

### Context
The client wants to automate branch deletion for **all repositories** under their organization. The requirement is to delete branches **only after they are merged via a PR** (not direct merges) and **exclude long-lived branches** (`main`, `master`, `dev`, `develop`, `preprod`, etc.). Most code hosting platforms (e.g., GitHub, GitLab) support this as a built-in setting.

### Proposed Behaviour
- Automatically delete branches after they are merged via a PR in all repositories.
- Exclude long-lived branches from deletion.
- Ensure the setting is applied consistently across the organization.

## Acceptance criteria
- [ ] Branches merged via PR are automatically deleted in all repositories.
- [ ] Long-lived branches (`main`, `master`, `dev`, `develop`, `preprod`, etc.) are **not** deleted.
- [ ] The setting is enabled at the organization level (or repository level if organization-wide is not possible).
- [ ] Direct merges (non-PR) do not trigger branch deletion.
- [ ] Verify the behaviour in a test repository before rolling out to all repositories.

RA Updated by Redmine Admin about 2 months ago Actions #1

  • Status changed from Submitted to Spec

Transition Submitted→Spec : ticket déjà spécifié (spec_ref=conversation:26, ticket unique non décomposé — tâche d'ops org-wide). Statut aligné sur l'état réel. Prêt pour dev.

RA Updated by Redmine Admin about 2 months ago Actions #2

  • Status changed from Spec to Blocked

BLOCKED — needs explicit infra authorization; cannot be safely auto-delivered. The naive fix (GitHub repo setting `delete_branch_on_merge=true`) would BREAK the omdev promotion pipeline: our flow merges PRs with head=`dev` (dev→preprod) and head=`preprod` (preprod→master), and GitHub deletes the HEAD branch of any merged PR — so it would delete `dev` and `preprod` on every promotion. Verified `dev`/`preprod`/`master` are currently NOT protected on PipeLiner-Client (and all 30+ omdev-tech repos have the setting off).

Safe implementation (requires owner sign-off, shared infra):
1. Add branch protection to long-lived branches (`main`/`master`, `dev`, `develop`, `preprod`) on each repo — GitHub does NOT auto-delete protected branches, so they survive promotion merges.
2. THEN enable `delete_branch_on_merge=true` so only merged feature-branch heads are cleaned up.
Alternative: a GitHub Action on PR-merge that deletes the head branch except an allow-list of long-lived names (avoids touching branch protection).

Scope note: ticket asks "all repositories" (30+ omdev-tech repos, incl. non-factory client products). Recommend confirming scope (factory repos only vs whole org) before rollout. Holding for authorization.

RA Updated by Redmine Admin about 2 months ago Actions #3

  • Status changed from Blocked to In development

Unblocked with a safe approach. Implemented a GitHub Action (PR #64) that auto-deletes merged feature branches with an explicit long-lived allow-list — avoids the native delete_branch_on_merge setting which would have deleted dev/preprod in our promotion flow. Shipping to pipeliner-client. NOTE: the ticket's "all repositories" org-wide rollout (29 other omdev-tech repos, incl. other client products) is NOT done autonomously — it needs explicit sign-off; the same workflow can be replicated per-repo once approved.

RA Updated by Redmine Admin about 2 months ago Actions #4

  • Status changed from In development to Shipped

Delivered for pipeliner-client and merged to master (master build #83, all stages green; prod healthy 307/200). The `.github/workflows/delete-merged-branch.yml` GitHub Action now auto-deletes a merged PR's head branch unless it is a long-lived branch (master/main/dev/develop/preprod/prod/production/staging/release) — satisfying "delete merged feature branches" + "exclude long-lived" without the unsafe native setting that would have deleted dev/preprod in our promotion flow.

REMAINING (org-wide): the ticket's "all repositories" rollout to the other ~29 omdev-tech repos (including other client products) was deliberately NOT done autonomously — replicating a branch-deletion automation across unrelated products needs explicit owner sign-off. Recommend a follow-up ticket to copy this same workflow into the other repos (or, where their long-lived branches are protected, enable the native delete_branch_on_merge). The AC item "verify in a test repository before rollout" also still applies to that rollout. Closing the pipeliner-client implementation → Shipped.

RA Updated by Redmine Admin about 2 months ago Actions #5

Owner decision: the org-wide rollout to the other omdev-tech repos is NOT wanted — do not replicate the branch-deletion automation across the other ~29 repos, and do not flip the native delete_branch_on_merge org-wide (it would delete dev/preprod and break those pipelines). This ticket is considered DONE with the pipeliner-client GitHub Action only; no follow-up ticket needed. Remains Shipped/closed.

Actions

Also available in: PDF Atom