Skip to content

Build Tools: Add workflow to label original PRs on manual cherry-pick…#77892

Open
Sahitya3105 wants to merge 5 commits intoWordPress:trunkfrom
Sahitya3105:fix/76579-cherry-pick-pr-tag
Open

Build Tools: Add workflow to label original PRs on manual cherry-pick…#77892
Sahitya3105 wants to merge 5 commits intoWordPress:trunkfrom
Sahitya3105:fix/76579-cherry-pick-pr-tag

Conversation

@Sahitya3105
Copy link
Copy Markdown

What?

Closes #76579

Adds a new GitHub Actions workflow (.github/workflows/label-manual-cherry-pick.yml) that automatically detects manual cherry-picks when a PR is merged to a wp/* or release/* branch and labels the original trunk PR with Backported to WP Core.

Why?

When the automatic cherry-pick workflow fails due to merge conflicts, contributors must manually git cherry-pick and create a PR to wp/* or release/* branches. However, they often forget to add the Backported to WP Core label to the original trunk PR, causing it to be missed in programmatically generated lists.

How?

The workflow triggers on pull_request_targetclosed (merged) events targeting wp/** or release/** branches and uses four detection strategies to find the original PR number:

  1. Explicit cherry-pick references in PR title/body — e.g., cherry-pick of #12345
  2. GitHub PR URL references — e.g., cherry-picked from https://github.com/WordPress/gutenberg/pull/12345
  3. Git's automatic annotation — resolves (cherry picked from commit <SHA>) from the merge commit to the original trunk PR via the GitHub API
  4. PR number in commit messages — extracts (#12345) patterns from squashed commit messages

After detection, it validates the original PR targets trunk, skips already-labeled PRs for idempotency, and applies the Backported to WP Core label.

Testing Instructions

This workflow only runs in WordPress/gutenberg when a PR is merged to wp/** or release/** branches. To verify:

  1. Review the workflow YAML for correctness.
  2. Confirm the regex patterns match expected cherry-pick reference formats (e.g., cherry-pick of #12345, cherry-picked from #12345).
  3. Verify the GitHub API calls are correct (git.getCommit, repos.listPullRequestsAssociatedWithCommit, pulls.get, issues.addLabels).
  4. Confirm the workflow follows project conventions (pinned action SHAs, permission model, runner version).

Testing Instructions for Keyboard

N/A — This is a CI workflow change with no UI modifications.

Screenshots or screencast

N/A — No UI changes.

Use of AI Tools

This PR was authored with the assistance of an AI coding assistant (Gemini) for code generation and review. All code has been reviewed and validated by the contributor.

WordPress#76579)

When a PR is merged to a wp/* or release/* branch and its title, body,
or commit message contains a cherry-pick reference, automatically add
the 'Backported to WP Core' label to the original trunk PR.

Detection strategies:
- Explicit 'cherry-pick of/from #N' in PR title/body
- GitHub PR URL references in cherry-pick context
- Git's automatic '(cherry picked from commit SHA)' annotation
- PR number patterns (#N) in merge commit messages
@Sahitya3105 Sahitya3105 requested a review from desrosj as a code owner May 2, 2026 19:51
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 2, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @Sahitya3105, @JiwaniZakir, @Kunal152000.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: Sahitya3105, JiwaniZakir, Kunal152000.

Co-authored-by: desrosj <desrosj@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions github-actions Bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label May 2, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 2, 2026

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @Sahitya3105! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@Sahitya3105
Copy link
Copy Markdown
Author

Could a maintainer please add the [Type] Build Tooling label? This PR adds a new GitHub Actions workflow. Thank you!

@t-hamano t-hamano added the [Type] Build Tooling Issues or PRs related to build tooling label May 4, 2026
@Sahitya3105
Copy link
Copy Markdown
Author

Hi! Just a gentle follow-up on this PR. All checks seem to be passing now—would appreciate a review when convenient. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Type] Build Tooling Issues or PRs related to build tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Original PRs may not be tagged properly when a manual cherry-pick is performed.

2 participants