From 13839bafeac3732286816cee06b0e56633dc5d51 Mon Sep 17 00:00:00 2001 From: Harish Seshadri Date: Thu, 19 Nov 2026 11:35:17 -0800 Subject: [PATCH] ci: clean orphan release branches only when no PR is open --- .github/workflows/release-please.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 6479f9b..1867ba0 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -55,11 +55,17 @@ jobs: # open its PR it still leaves the release branch behind; delete that # orphan so the branches page never shows unmerged release work. - name: Remove an orphan release branch on failure - if: steps.release.outcome == 'failure' + if: always() && steps.release.outcome == 'failure' env: GH_TOKEN: ${{ github.token }} RELEASE_BRANCH: release-please--branches--main--components--errors - run: gh api -X DELETE "repos/$GITHUB_REPOSITORY/git/refs/heads/$RELEASE_BRANCH" || true + run: | + open_prs="$(gh pr list --repo "$GITHUB_REPOSITORY" --head "$RELEASE_BRANCH" --state open --json number --jq 'length')" + if [ "$open_prs" != "0" ]; then + echo "Keeping $RELEASE_BRANCH because an open release PR exists." + exit 0 + fi + gh api -X DELETE "repos/$GITHUB_REPOSITORY/git/refs/heads/$RELEASE_BRANCH" || true - name: Publish the release (dispatch publish.yml at the new tag) if: ${{ steps.release.outputs.release_created == 'true' }}