Skip to content

ci: fix release pipeline race condition in PR lookup after squash merge#4

Merged
nilsandrey merged 5 commits into
mainfrom
copilot/investigate-pipeline-issues
Mar 8, 2026
Merged

ci: fix release pipeline race condition in PR lookup after squash merge#4
nilsandrey merged 5 commits into
mainfrom
copilot/investigate-pipeline-issues

Conversation

Copilot AI commented Mar 8, 2026

Copy link
Copy Markdown
Contributor

Fix release pipeline race condition: add retry logic and commit-message fallback for PR lookup after squash merges.

Problem

PR #3's squash merge triggered the release workflow within 3 seconds. The gh api commits/{sha}/pulls call returned empty — GitHub hadn't indexed the commit→PR association yet. This set bump_type=none, skipping all release steps (version bump, changelog, GitHub Release creation).

Fix

Three resilience mechanisms added to the "Determine version bump" step:

  • Retry with backoff — commits/pulls API retries 3× with increasing delay (5s, 10s), skipping the sleep after the final attempt
  • Commit-message fallback — if retries exhaust, extracts PR number from the squash-merge commit subject (Title (#N), using the last match to avoid picking up issue references) and looks up the PR directly by number
  • API error surfacinggh api errors are now captured and logged as ::warning:: annotations (retryable calls) or ::error:: with immediate job failure (direct PR lookup), instead of being silently swallowed via 2>/dev/null || echo ""
# Retry with error surfacing
GH_ERR_FILE="$RUNNER_TEMP/gh_api_err_$$"
PR_DATA=$(gh api "repos/.../commits/$SHA/pulls" \
  --jq '.[0] // empty' 2>"$GH_ERR_FILE") || API_ERR=$(cat "$GH_ERR_FILE")

# Fallback: extract PR number from squash-merge commit message "(#N)"
if [ -z "$PR_DATA" ]; then
  PR_NUMBER=$(git log -1 --format=%s "$COMMIT_SHA" | grep -oE '\(#[0-9]+\)' | tail -1 | tr -d '(#)')
  if [ -n "$PR_NUMBER" ]; then
    PR_DATA=$(gh api "repos/.../pulls/$PR_NUMBER" 2>"$GH_ERR_FILE") || API_ERR=$(cat "$GH_ERR_FILE")
    if [ -n "$API_ERR" ]; then
      echo "::error::Failed to fetch PR #$PR_NUMBER: $API_ERR"
      exit 1
    fi
  fi
fi

Type of Change

  • Major – Breaking change (requires a new major version bump)
  • Minor – New feature, backward-compatible (requires a new minor version bump)
  • Patch – Bug fix or internal improvement, backward-compatible (requires a new patch version bump)

Next steps

Merging this PR serves as the initial release trigger — the fixed pipeline will bump 1.0.01.0.1 and create the first GitHub Release. Edit the checkbox above to Minor before merge if v1.1.0 is preferred.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: nilsandrey <3579285+nilsandrey@users.noreply.github.com>
Copilot AI changed the title [WIP] Investigate skipped steps in CI pipeline ci: fix release pipeline race condition in PR lookup after squash merge Mar 8, 2026
@nilsandrey
nilsandrey requested review from acollazo25 and Copilot March 8, 2026 17:37
@nilsandrey
nilsandrey marked this pull request as ready for review March 8, 2026 17:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the GitHub Actions release workflow’s ability to reliably find the merged PR associated with a push to main, addressing GitHub’s delayed commit→PR indexing after squash merges so releases aren’t skipped.

Changes:

  • Add retry logic with increasing delays for the commits/{sha}/pulls PR lookup.
  • Add a commit-subject fallback that extracts (#N) and fetches the PR directly when the commits/pulls lookup remains empty.

Comment thread .github/workflows/release.yml Outdated
Comment thread .github/workflows/release.yml Outdated
Comment thread .github/workflows/release.yml
Comment thread .github/workflows/release.yml
nilsandrey and others added 2 commits March 8, 2026 11:40
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: nilsandrey <3579285+nilsandrey@users.noreply.github.com>
@nilsandrey
nilsandrey merged commit c1707dc into main Mar 8, 2026
1 check passed
@nilsandrey
nilsandrey deleted the copilot/investigate-pipeline-issues branch March 8, 2026 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants