From 9ecbe117715b7e8d2d376511aba33dcc2fdb7bcd Mon Sep 17 00:00:00 2001 From: Collin Diekvoss Date: Thu, 20 Aug 2026 15:13:58 -0500 Subject: [PATCH] fix(ci): don't delete update-flake-lock branch on failed merge The merge job deleted the PR branch unconditionally after attempting the squash merge, even when the merge itself failed (e.g. HTTP 405). That's why PR #8 closed with the branch gone but no commit landed - the merge failed and cleanup ran anyway. Now the branch is only deleted after a confirmed 200/201, and the job exits non-zero on any other outcome so it's visible in the run status instead of silently continuing. Also add a concurrency group, since update/build/push/schedule/PR triggers overlapping could race two merge attempts against the same PR. --- .forgejo/workflows/build.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml index ae70e49..566e0a9 100644 --- a/.forgejo/workflows/build.yml +++ b/.forgejo/workflows/build.yml @@ -17,6 +17,9 @@ on: # rebuild everyday at 8:26 - cron: "26 8 * * *" workflow_dispatch: +concurrency: + group: ${{ github.workflow }} + cancel-in-progress: false env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} jobs: @@ -144,10 +147,13 @@ jobs: "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER/merge" \ -o /tmp/merge_response.json) + MERGE_OK=false if [ "$MERGE_RESPONSE" = "200" ]; then echo "Successfully merged PR #$PR_NUMBER" + MERGE_OK=true elif [ "$MERGE_RESPONSE" = "201" ]; then echo "Successfully merged PR #$PR_NUMBER (created)" + MERGE_OK=true elif [ "$MERGE_RESPONSE" = "405" ]; then echo "PR #$PR_NUMBER already merged or merge not allowed (HTTP 405)" elif [ "$MERGE_RESPONSE" = "404" ]; then @@ -157,7 +163,11 @@ jobs: else echo "Merge failed with HTTP $MERGE_RESPONSE" cat /tmp/merge_response.json 2>/dev/null || echo "No response body" - echo "Continuing anyway..." + fi + + if [ "$MERGE_OK" != true ]; then + echo "Merge did not succeed, leaving branch $BRANCH in place for investigation" + exit 1 fi echo "Attempting to delete branch $BRANCH..." -- 2.51.2