Skip to content

Add backport-pr skill#7843

Open
mazhelez wants to merge 4 commits intomainfrom
mazhelez/backport-pr-skill
Open

Add backport-pr skill#7843
mazhelez wants to merge 4 commits intomainfrom
mazhelez/backport-pr-skill

Conversation

@mazhelez
Copy link
Copy Markdown
Contributor

@mazhelez mazhelez commented Apr 23, 2026

Adds a reusable Copilot skill at .github/skills/backport-pr/SKILL.md that automates backporting a PR from main to one or more releases/* branches.

The skill wraps New-BCAppsBackport from build/scripts/CrossBranchPorting.psm1 and codifies the conventions we follow when backporting:

  • Pre-flight checks: gh auth, PR mergeability (mergeCommit / potentialMergeCommit), target branch existence, clean working tree.
  • Per-branch ADO work item resolution by default — looks up the linked/child work item that targets each release branch instead of reusing the parent work item from the source PR. Bulk -ReuseWorkItem mode is documented as opt-in only.
  • Recovery steps for the transient git push failures we sometimes hit, so the agent doesn't restart the whole batch.
  • Optional auto-merge step (gh pr merge --auto --squash) at the end.
  • Pitfalls list (glob expansion picking up old releases/*, blocked auto-merge, dirty worktree, etc.).

Discoverable via trigger phrases: backport a PR, port to releases/*, cherry-pick to a release branch, propagate a change to release branches.

Generated from the workflow used to backport #7830 to the 27.* and 28.* branches (#7832, #7834#7841).

AB#612711

Copilot AI review requested due to automatic review settings April 23, 2026 14:20
@mazhelez mazhelez requested a review from a team as a code owner April 23, 2026 14:20
@github-actions github-actions Bot added the Build: Automation Workflows and other setup in .github folder label Apr 23, 2026
@github-actions github-actions Bot added this to the Version 29.0 milestone Apr 23, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a reusable Copilot skill that documents and standardizes the repo’s backport workflow (via New-BCAppsBackport) for creating backport PRs from main to one or more releases/* branches, including preflight checks, per-branch ADO work item handling guidance, and optional auto-merge.

Changes:

  • Introduces .github/skills/backport-pr/SKILL.md describing the end-to-end backport procedure and conventions.
  • Documents per-branch ADO work item resolution as the default (with -ReuseWorkItem as opt-in).
  • Includes recovery guidance for transient push failures and an optional auto-merge step.

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

Comment thread .github/skills/backport-pr/SKILL.md Outdated
Comment thread .github/skills/backport-pr/SKILL.md Outdated
Comment on lines +63 to +67
$backportPr = gh pr list --repo microsoft/BCApps --state open --search "[$branch] in:title $pr in:body" --json number,body,url | ConvertFrom-Json | Select-Object -First 1
if ($backportPr) {
$newBody = $backportPr.body -replace '\[\*\*Insert Work Item Number Here\*\*\]', $map[$branch]
gh pr edit $backportPr.number --repo microsoft/BCApps --body $newBody
}
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

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

The PR-body patch step finds the created backport PR via a broad gh pr list --search ... | Select-Object -First 1, which can select the wrong PR (or none) if multiple open PRs match the query or if GitHub search indexing lags. Consider filtering deterministically (e.g., include --base <branch> and/or match the exact title the script generates) and adding a small retry loop before editing the body.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

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.

Updated in 8f63040: the PR lookup is now deterministic (--base + exact generated title match), includes a retry loop to handle indexing lag, and warns if no PR is found after retries. I also added a guard for missing source PR title before entering the loop.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI and others added 2 commits April 23, 2026 15:23
Copy link
Copy Markdown
Contributor

@Groenbech96 Groenbech96 left a comment

Choose a reason for hiding this comment

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

Love it. Could we put this in a marketplace so that is is opt in?

@mazhelez mazhelez enabled auto-merge (squash) April 23, 2026 18:10
@mazhelez
Copy link
Copy Markdown
Contributor Author

Love it. Could we put this in a marketplace so that is is opt in?

It's quite related to BCApps and the backporting tool that already exists. Not sure if placing it in a marketplace is worth it.

@Groenbech96
Copy link
Copy Markdown
Contributor

Love it. Could we put this in a marketplace so that is is opt in?

It's quite related to BCApps and the backporting tool that already exists. Not sure if placing it in a marketplace is worth it.

That becomes an issue over time, as more and more skills we be added and forced on people that are working in BCApps. To keep it clean, a marketplace provides a repository you opt into and is available here in BCApps. I would suggest to add the the README and overview of the marketplace and how to install the plugin, what it does etc.

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

Labels

Build: Automation Workflows and other setup in .github folder

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants