From 4540a22dfe1851442e4e9fef3b2c765e9f151bd1 Mon Sep 17 00:00:00 2001 From: "privilegedescalation-engineer[bot]" <269729446+privilegedescalation-engineer[bot]@users.noreply.github.com> Date: Wed, 25 Mar 2026 07:29:17 +0000 Subject: [PATCH] fix(release): improve merge error handling to handle already-merged PRs (#76) Check PR state before attempting merge to avoid 'branch not found' errors when a prior run's auto-merge already completed. Fallback merge should now handle all cases without spurious step failures. Fixes: https://github.com/privilegedescalation/.github/issues/75 Co-authored-by: Hugh Hackman Co-authored-by: Paperclip --- .github/workflows/plugin-release.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/plugin-release.yaml b/.github/workflows/plugin-release.yaml index 82c4870..a5c3b51 100644 --- a/.github/workflows/plugin-release.yaml +++ b/.github/workflows/plugin-release.yaml @@ -277,8 +277,12 @@ jobs: # Try auto-merge first (works on repos with required status checks pending). # Fall back to direct squash merge on repos without required status checks # (auto-merge is rejected when there are no pending required checks to wait for). - if ! gh pr merge "release/v${VERSION}" --auto --squash --delete-branch 2>/dev/null; then - echo "Auto-merge not available (no pending required status checks). Falling back to direct squash merge." + # If PR is already merged, skip entirely to avoid "branch not found" errors. + PR_STATE=$(gh pr view "release/v${VERSION}" --json state --jq '.state' 2>/dev/null || echo "unknown") + if [ "$PR_STATE" = "MERGED" ]; then + echo "PR release/v${VERSION} is already merged. Skipping merge step." + elif ! gh pr merge "release/v${VERSION}" --auto --squash --delete-branch 2>&1; then + echo "Auto-merge not available (no pending required status checks or other constraint). Falling back to direct squash merge." gh pr merge "release/v${VERSION}" --squash --delete-branch fi env: