Add GitHub Actions workflow to automate cherry-pick hotfix PRs#4106
Merged
paulmedynski merged 14 commits intomainfrom Apr 6, 2026
Merged
Add GitHub Actions workflow to automate cherry-pick hotfix PRs#4106paulmedynski merged 14 commits intomainfrom
paulmedynski merged 14 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new GitHub Actions workflow to automate creating cherry-pick PRs from merged hotfix PRs onto corresponding release/* branches based on Hotfix <version> labels, streamlining the hotfix backport process.
Changes:
- Introduces
.github/workflows/cherry-pick-hotfix.ymltriggered bypull_requestclosedandlabeledevents. - Detects hotfix versions from PR labels and fans out a matrix job (one cherry-pick per version).
- Creates either a normal cherry-pick PR or a “CONFLICTS” placeholder PR with manual resolution instructions.
paulmedynski
commented
Mar 31, 2026
eng/pipelines/dotnet-sqlclient-ci-project-reference-pipeline.yml
Outdated
Show resolved
Hide resolved
eng/pipelines/dotnet-sqlclient-ci-package-reference-pipeline.yml
Outdated
Show resolved
Hide resolved
Codecov Report✅ All modified and coverable lines are covered by tests.
Additional details and impacted files@@ Coverage Diff @@
## main #4106 +/- ##
==========================================
- Coverage 73.22% 66.48% -6.75%
==========================================
Files 280 274 -6
Lines 43000 65782 +22782
==========================================
+ Hits 31486 43732 +12246
- Misses 11514 22050 +10536
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
269ef41 to
dd13252
Compare
…Hotfix X.Y.Z" labels.
…aming - Switch from pull_request to pull_request_target so fork PRs have write permissions for push and PR creation. - Detect parent count before cherry-pick: only pass --mainline 1 for true merge commits (2+ parents), omit it for squash merges. - Parse major.minor from the Hotfix label version for the target release branch name (e.g. 'Hotfix 7.0.1' targets release/7.0), while preserving the full version in PR titles, milestones, and cherry-pick branch names.
…bel validation - Remove --count from git rev-list so parent detection works correctly for both merge and squash-merge commits - Use CHERRY_PICK_BRANCH variable in conflict resolution instructions instead of hardcoded branch prefix - Tighten Hotfix label regex to only accept X.Y.Z semver format
…estone lookup, MAINLINE_FLAG in body, CI indentation - Add default-branch guard to prevent recursive cherry-picks from release branches - For 'labeled' events, only process the newly added label; skip if cherry-pick branch or PR already exists - Look up milestone before creating PR; if missing, omit --milestone and add a note to the PR description - Build CHERRY_PICK_CMD conditionally so empty MAINLINE_FLAG doesn't produce trailing '' in conflict-resolution instructions - Fix CI pipeline branch list indentation under include:
Add a pre-check using 'git cherry' to determine if the merge commit's patch is already present on the target release branch. If so, the job exits cleanly with a notice instead of producing an empty commit or a misleading CONFLICTS PR.
Move inline shell scripts from cherry-pick-hotfix.yml into standalone files under .github/scripts/: - extract-hotfix-versions.sh: Parses 'Hotfix X.Y.Z' labels from PR metadata and emits a JSON version matrix for fan-out. - cherry-pick-to-release.sh: Cherry-picks a merge commit onto the corresponding release branch and opens a PR (or a CONFLICTS PR with manual resolution instructions). Both scripts include: - Full header documentation with overview, env vars, and examples - Runtime --help / -h support - Input validation with clear error messages - Comments on all non-obvious operations Add bats-core test suites under .github/scripts/tests/: - 18 tests for extract-hotfix-versions.sh (label parsing, edge cases, duplicate detection, event-type handling) - 15 tests for cherry-pick-to-release.sh (version derivation, already-applied detection, merge type handling, milestone lookup, conflict path) Also fixes a quoting bug in the MILESTONE_NOTE assignment that caused 'command not found' when the milestone didn't exist.
- Replace git ls-remote with gh api for branch existence check in extract-hotfix-versions.sh (detect-versions job has no checkout) - Put cherry-pick options (--mainline 1) before SHA operand - Fix conflict-resolution command to put options before SHA - Update bats test mocks to match new gh api usage
…ITORY validation - Replace duplicated --help heredocs with awk extraction of the header comment block in both scripts, eliminating content drift. - Add GITHUB_REPOSITORY to required env var validation in extract-hotfix-versions.sh (was used with set -u but not validated). - Pass --repo to 'gh pr list' so it works without a .git directory. - Set GITHUB_REPOSITORY in bats test setup() for deterministic runs. - Update test assertions to match uppercase header comment headings.
c3f3d2f to
00ed23a
Compare
- Add checkout step to detect-versions job so scripts exist on runner - Fix git cherry invocation (remove incorrect limit argument) - Replace grep -oP with portable bash regex for macOS compat - Replace GNU sed \+ with sed -E / bash regex for portability - Document jq and gh prerequisites in test README
mdaigle
reviewed
Apr 2, 2026
eng/pipelines/dotnet-sqlclient-ci-project-reference-pipeline.yml
Outdated
Show resolved
Hide resolved
- Fix git cherry arg order: scope already-applied check to the exact PR commit - Guard cherry-pick job with if-condition when matrix is empty ([]) - Fix ::set-output:: reference in test README (scripts use $GITHUB_OUTPUT) - Fix 'pipline' typo in both CI pipeline YAML files - Scope milestones API call to open milestones only (--field state=open)
mdaigle
approved these changes
Apr 6, 2026
apoorvdeshmukh
approved these changes
Apr 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a new GitHub Actions workflow (
.github/workflows/cherry-pick-hotfix.yml) that automates cherry-picking merged PRs into release branches when a "Hotfix <version>" label is present.How it works:
release/<version>.closedandlabeledevents.[<version> Cherry-pick] <original title>.[<version> Cherry-pick - CONFLICTS] <original title>, with manual resolution instructions in the body.Engineering processes (CI, pipelines):
Issues
No linked issue — this is a new engineering workflow to streamline the hotfix process.
Testing
Guidelines
Please review the contribution guidelines before submitting a pull request: