Handle issues:labeled trigger for cherry-pick on already-merged PRs - #71
Closed
bunnam988 wants to merge 3 commits into
Closed
Handle issues:labeled trigger for cherry-pick on already-merged PRs#71bunnam988 wants to merge 3 commits into
bunnam988 wants to merge 3 commits into
Conversation
- Remove set -e; add error handling around push/PR create so loop continues - Fix commit range for squash/rebase merges via PR API commit count - Fix empty cherry-pick detection: use stderr grep instead of fragile diff check - Fix unquoted LABEL_ARGS: separate gh pr create calls per label presence - Add --limit 100 to all gh search prs calls (was silently capping at 30) - Fix jq -s 'add' -> 'add // []' to prevent null on empty array inputs - Fix ticket regex [A-Z0-9]+ -> [A-Z][A-Z0-9]+ to match rdkcentral format - Add CROSS_REPO_TOKEN secret input to shared gatekeeper for org-wide search
- Add pr_number_override input to support triggering from issues:labeled event - Fetch PR context (title, URL, merge SHA) via API when pull_request context is empty - Fix CURRENT_PR_URL in parse_meta for issues event using format() expression
Contributor
There was a problem hiding this comment.
Pull request overview
Adds reusable GitHub Actions workflows for cross-repo backporting and merge gating, including support for applying cherry-pick to <branch> labels to already-merged PRs via an issues:labeled trigger workaround.
Changes:
- Introduces a shared cherry-pick engine reusable workflow with
pr_number_overrideto supportissues:labeledon merged PRs. - Adds a shared cross-repo gatekeeper reusable workflow that audits “sister” PRs for required approvals (and missing release/support backports).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| .github/workflows/cherry-pick.yml | New reusable workflow to propagate cherry-pick labels cross-repo and create backport PRs, including post-merge labeling support via PR-number override. |
| .github/workflows/gatekeeper.yml | New reusable workflow to block/allow merges based on cross-repo PR approval status (and stable-branch cherry-pick completeness checks). |
Suppressed comments (1)
.github/workflows/gatekeeper.yml:35
grepreturns exit code 1 when there are no matches. With GitHub Actions’ defaultbash -e -o pipefail, both of these command substitutions can abort the job on PRs that have only ticket IDs (notopic:label) or no ticket IDs at all (the intendedskip validationbranch is never reached).
ALL_IDS=$(echo -e "${PR_TITLE}\n${PR_BODY}" | grep -oE '[A-Z][A-Z0-9]+-[0-9]+' | sort -u)
# Extract any user-defined custom topic label (e.g., topic:billing-engine-v2)
CUSTOM_TOPIC=$(echo "$PR_DATA" | jq -r '.labels[].name' 2>/dev/null | grep "^topic:" | head -n 1)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| TARGET_BRANCHES=$(echo '${{ inputs.raw_labels }}' | jq -r '.[] | .name' | grep "cherry-pick to " | sed 's/cherry-pick to //' || true) | ||
| fi | ||
|
|
||
| CUSTOM_TOPIC=$(echo '${{ inputs.raw_labels }}' | jq -r '.[] | .name' | grep "^topic:" | head -n 1) |
| ORIGINAL_REPOS=$(echo "$HISTORICAL_PRS" | jq -r '.[].repository.name' | sort -u) | ||
|
|
||
| while read -r repo; do | ||
| if [ -n "$repo" ] && ! echo "$REPOS_WITH_RELEASE_PRS" | grep -q "^$repo$"; then |
| @@ -0,0 +1,215 @@ | |||
| name: Shared Cross-Repo Gatekeeper | |||
Contributor
Author
|
Closing — replaced by a clean single-commit PR from the correct base. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Follow-up to #70. Adds support for adding a
cherry-pick to <branch>label to a PR that was already merged days/weeks ago.Problem: GitHub does not fire
pull_request: labeledevents on closed/merged PRs, so labels added after merge were silently ignored.Fix:
pr_number_overrideinput to the shared engineissues: labeledon a merged PR, fetches PR title, URL and merge SHA from the APIstate != MERGEDcheck)CURRENT_PR_URLin the propagation step constructed correctly for the issues eventReason for change: Enable cherry-pick labels to be added at any time after merge
Test Procedure: Add label to an already-merged PR — workflow fires and creates backport PR
Risks: Low
Priority: P1