Skip to content

Handle issues:labeled trigger for cherry-pick on already-merged PRs - #72

Merged
GoutamD2905 merged 1 commit into
rdkcentral:developfrom
bunnam988:fix/cherry-pick-issues-labeled-trigger
Aug 7, 2026
Merged

Handle issues:labeled trigger for cherry-pick on already-merged PRs#72
GoutamD2905 merged 1 commit into
rdkcentral:developfrom
bunnam988:fix/cherry-pick-issues-labeled-trigger

Conversation

@bunnam988

Copy link
Copy Markdown
Contributor

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: labeled events on closed/merged PRs, so labels added after merge were silently ignored.

Fix:

  • Added pr_number_override input to the shared engine
  • When triggered via issues: labeled on a merged PR, fetches PR title, URL and merge SHA from the API
  • Guards against running on non-merged PRs (state != MERGED check)
  • CURRENT_PR_URL in the propagation step constructed correctly for the issues event

Reason 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

- 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
@bunnam988
bunnam988 requested a review from a team as a code owner August 7, 2026 08:26
Copilot AI review requested due to automatic review settings August 7, 2026 08:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds support to the shared cherry-pick reusable workflow for being triggered from an issues:labeled event on already-merged PRs (where github.event.pull_request context is unavailable), by allowing the caller to pass an explicit PR number and fetching PR metadata via the GitHub API.

Changes:

  • Introduces a pr_number_override input for post-merge issues:labeled scenarios.
  • Constructs CURRENT_PR_URL from the override to keep label-propagation “self” detection working.
  • When override is used, fetches PR title/URL/merge SHA via gh pr view and skips if the PR isn’t merged.
Suppressed comments (1)

.github/workflows/cherry-pick.yml:144

  • If merge_commit_sha is empty (e.g., labeled event on an open PR or a closed-but-unmerged PR), MERGE_SHA becomes empty and the subsequent git commands can operate on an invalid ref. Add an explicit guard before attempting to resolve commits.
          # Resolve commits that landed on base branch, handling all merge strategies
          MERGE_SHA="${MERGE_SHA:-${{ github.event.pull_request.merge_commit_sha }}}"
          if git cat-file -e "${MERGE_SHA}^2" 2>/dev/null; then

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/cherry-pick.yml
Comment thread .github/workflows/cherry-pick.yml
@GoutamD2905
GoutamD2905 merged commit 3b62dd4 into rdkcentral:develop Aug 7, 2026
3 of 4 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants