[llvm] [Github] Make prune-unused-branches workflow prune branches (PR #178769)
Aiden Grossman via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 29 14:48:07 PST 2026
https://github.com/boomanaiden154 created https://github.com/llvm/llvm-project/pull/178769
This adds in the final piece to the workflow to actually delete unused user branches. For now this is limited to my branches so we can validate this a little more in the production environment before starting to delete all branches.
>From 92d5d59aa705f1804ab3f7e8e66489feadc47785 Mon Sep 17 00:00:00 2001
From: Aiden Grossman <aidengrossman at google.com>
Date: Thu, 29 Jan 2026 22:46:34 +0000
Subject: [PATCH] [Github] Make prune-unused-branches workflow prune branches
This adds in the final piece to the workflow to actually delete unused
user branches. For now this is limited to my branches so we can validate
this a little more in the production environment before starting to
delete all branches.
---
.github/workflows/prune-branches.yml | 2 ++
.github/workflows/prune-unused-branches.py | 23 +++++++++++++++++++++-
2 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/prune-branches.yml b/.github/workflows/prune-branches.yml
index f3550b35aadd2..73a1e6a97bee8 100644
--- a/.github/workflows/prune-branches.yml
+++ b/.github/workflows/prune-branches.yml
@@ -15,6 +15,8 @@ jobs:
name: Prune Branches
if: github.repository_owner == 'llvm'
runs-on: ubuntu-24.04
+ permissions:
+ contents: write
steps:
- name: Fetch LLVM sources
uses: actions/checkout at 8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
diff --git a/.github/workflows/prune-unused-branches.py b/.github/workflows/prune-unused-branches.py
index 1aff0aeef75ab..2889c54b0f6dc 100644
--- a/.github/workflows/prune-unused-branches.py
+++ b/.github/workflows/prune-unused-branches.py
@@ -98,6 +98,26 @@ def generate_patches_for_all_branches(branches_to_remove: list[str], patches_pat
)
+def delete_branches(branches_to_remove: list[str]):
+ for branch in branches_to_remove:
+ # TODO(boomanaiden154): Only delete my branches for now to verify that
+ # everything is working in the production environment.
+ if "boomanaiden154" not in branch:
+ continue
+ command_vector = ["git", "push", "-d", "origin", branch]
+ try:
+ subprocess.run(
+ command_vector,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ check=True,
+ )
+ except subprocess.CalledProcessError as process_error:
+ print(process_error.stderr)
+ print(process_error.stdout)
+ print(f"Deleted branch {branch}")
+
+
def main(github_token):
if len(sys.argv) != 2:
print(
@@ -113,7 +133,8 @@ def main(github_token):
user_branches, user_branches_from_prs
)
print(f"Deleting {len(user_branches_to_remove)} user branches.")
- generate_patches_for_all_branches(user_branches_to_remove, sys.argv[1])
+ # generate_patches_for_all_branches(user_branches_to_remove, sys.argv[1])
+ delete_branches(user_branches_to_remove)
if __name__ == "__main__":
More information about the llvm-commits
mailing list