From ae6e7e6364b1479d8082db32bc3e5d255fb7f43b Mon Sep 17 00:00:00 2001 From: Conor Hoekstra Date: Sun, 6 Sep 2026 22:44:48 -0400 Subject: [PATCH] Clean up merged auto-update branches --- .../cleanup-auto-update-branches.yml | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/cleanup-auto-update-branches.yml diff --git a/.github/workflows/cleanup-auto-update-branches.yml b/.github/workflows/cleanup-auto-update-branches.yml new file mode 100644 index 0000000..2bfd868 --- /dev/null +++ b/.github/workflows/cleanup-auto-update-branches.yml @@ -0,0 +1,30 @@ +name: Clean up merged auto-update branches + +on: + pull_request: + types: [closed] + +# Deleting a branch updates a Git reference in this repository. +permissions: + contents: write + +jobs: + delete-branch: + # Only touch merged automation PRs whose branch belongs to this repository. + # This excludes closed-but-unmerged PRs, forks, and ordinary feature branches. + if: >- + github.event.pull_request.merged == true && + github.event.pull_request.head.repo.full_name == github.repository && + startsWith(github.event.pull_request.head.ref, 'auto/update-') + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - name: Delete merged update branch + env: + GH_TOKEN: ${{ github.token }} + BRANCH: ${{ github.event.pull_request.head.ref }} + REPOSITORY: ${{ github.repository }} + run: | + gh api \ + --method DELETE \ + "repos/${REPOSITORY}/git/refs/heads/${BRANCH}"