From 935b822a394ad58e5ea6b4d4b9b02e15d5c8bf62 Mon Sep 17 00:00:00 2001 From: Endkind Date: Sun, 15 Jun 2025 23:03:54 +0200 Subject: [PATCH] =?UTF-8?q?f=C3=BCge=20Workflow=20zum=20L=C3=B6schen=20von?= =?UTF-8?q?=20zusammengef=C3=BChrten=20Branches=20hinzu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/delete-merged-branch.yml | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/delete-merged-branch.yml diff --git a/.github/workflows/delete-merged-branch.yml b/.github/workflows/delete-merged-branch.yml new file mode 100644 index 0000000..96181c1 --- /dev/null +++ b/.github/workflows/delete-merged-branch.yml @@ -0,0 +1,23 @@ +name: Delete merged branch + +on: + pull_request: + types: + - closed + +jobs: + delete-branch: + if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' + runs-on: ubuntu-latest + steps: + - name: Delete merged branch + run: | + branch="${{ github.event.pull_request.head.ref }}" + repo="${{ github.repository }}" + token="${{ secrets.GITHUB_TOKEN }}" + if [[ "$branch" != "main" && "$branch" != "master" ]]; then + curl -s -X DELETE \ + -H "Authorization: Bearer $token" \ + -H "Accept: application/vnd.github+json" \ + "https://api.github.com/repos/$repo/git/refs/heads/$branch" + fi