From 34550add3ee85bab6fe1c670dff46871d1a41e04 Mon Sep 17 00:00:00 2001 From: Henry Park Date: Wed, 11 Mar 2026 12:04:54 -0700 Subject: [PATCH] fix(ci): prevent staging-ci tag failure and chained PR auto-close (#900) - Use fetch-depth: 0 in update-tag to ensure current_head SHA is available even when staging receives new commits during the CI run - Only merge promotion PRs targeting main; leave chained PRs open to prevent delete_branch_on_merge from auto-closing downstream PRs Co-authored-by: Claude Opus 4.6 --- .github/workflows/staging-ci.yml | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/.github/workflows/staging-ci.yml b/.github/workflows/staging-ci.yml index 8e3693b2..c8a39c80 100644 --- a/.github/workflows/staging-ci.yml +++ b/.github/workflows/staging-ci.yml @@ -406,6 +406,10 @@ jobs: echo "passed=true" >> "$GITHUB_OUTPUT" fi + # Only merge PRs targeting main. Chained PRs (targeting another + # promotion branch) stay open — when the base PR merges into main, + # GitHub auto-retargets the chained PR. Merging chained PRs would + # trigger delete_branch_on_merge, auto-closing downstream PRs. - name: Merge promotion PR id: merge if: steps.evaluate.outputs.passed == 'true' @@ -414,12 +418,15 @@ jobs: PR_NUMBER: ${{ needs.create-promotion-pr.outputs.pr_number }} run: | if [ -n "$PR_NUMBER" ]; then - echo "Merging promotion PR #${PR_NUMBER}" - # Do NOT use --delete-branch: deleting a promotion branch closes - # any chained PRs that use it as their base (verified in ironclaw-ci-test). - # Stale promotion branches are cleaned up separately. - gh pr merge "$PR_NUMBER" --merge - echo "merged=true" >> "$GITHUB_OUTPUT" + BASE=$(gh pr view "$PR_NUMBER" --json baseRefName --jq '.baseRefName') + if [ "$BASE" = "main" ]; then + echo "Merging promotion PR #${PR_NUMBER} (targets main)" + gh pr merge "$PR_NUMBER" --merge + echo "merged=true" >> "$GITHUB_OUTPUT" + else + echo "PR #${PR_NUMBER} targets '${BASE}' (not main) — leaving open for chain resolution" + echo "merged=false" >> "$GITHUB_OUTPUT" + fi fi # ── Update tested tag (always, so next batch covers only new commits) ── @@ -437,7 +444,7 @@ jobs: - uses: actions/checkout@v6 with: ref: staging - fetch-depth: 1 + fetch-depth: 0 - name: Update staging-tested tag run: |