This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 346026b4de9f CAMEL-22995: Auto-delete automated/upgrade branches on PR 
close (#22096)
346026b4de9f is described below

commit 346026b4de9f8160571a31e923bce07d8921fdf3
Author: Guillaume Nodet <[email protected]>
AuthorDate: Thu Mar 19 10:20:27 2026 +0100

    CAMEL-22995: Auto-delete automated/upgrade branches on PR close (#22096)
    
    Add a workflow that automatically deletes branches matching
    `automated/upgrade*` when their associated PR is closed or merged.
    Only acts on branches owned by the repo (not forks).
    
    Co-authored-by: Claude Opus 4.6 <[email protected]>
---
 .github/workflows/pr-cleanup-branches.yml | 42 +++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/.github/workflows/pr-cleanup-branches.yml 
b/.github/workflows/pr-cleanup-branches.yml
new file mode 100644
index 000000000000..3871f49af0df
--- /dev/null
+++ b/.github/workflows/pr-cleanup-branches.yml
@@ -0,0 +1,42 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+name: PR Cleanup Branches
+
+on:
+  pull_request_target:
+    types: [closed]
+
+permissions:
+  contents: write
+
+jobs:
+  cleanup:
+    name: Delete automated branch
+    if: >-
+      github.repository == 'apache/camel'
+      && github.event.pull_request.head.repo.full_name == 
github.event.repository.full_name
+      && startsWith(github.event.pull_request.head.ref, 'automated/upgrade')
+    runs-on: ubuntu-latest
+    steps:
+      - name: Delete branch
+        env:
+          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+          BRANCH: ${{ github.event.pull_request.head.ref }}
+        run: |
+          echo "Deleting branch: $BRANCH"
+          gh api -X DELETE "repos/${{ github.repository 
}}/git/refs/heads/$BRANCH" || echo "Branch already deleted"

Reply via email to