Skip to content

Add GitOps policy to auto-label backport candidates when CL-BuildPackaging is added#26881

Merged
daxian-dbw merged 2 commits into
masterfrom
copilot/add-gitops-pr-issue-management-policy
Feb 23, 2026
Merged

Add GitOps policy to auto-label backport candidates when CL-BuildPackaging is added#26881
daxian-dbw merged 2 commits into
masterfrom
copilot/add-gitops-pr-issue-management-policy

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 23, 2026

Adds a new GitOps.PullRequestIssueManagement policy that automatically applies BackPort-7.4.x-Consider, BackPort-7.5.x-Consider, and BackPort-7.6.x-Consider labels whenever CL-BuildPackaging is added to an open PR targeting master.

Changes

  • .github/policies/labelAdded.clBuildPackaging.addBackportConsider.yml — new policy file with:
    • Three eventResponderTasks, one per backport label
    • Each task guards with not: hasLabel to prevent duplicate label application
    • Conditions: payloadType: Pull_Request + isOpen + labelAdded: CL-BuildPackaging + targetsBranch: master

Three separate tasks (rather than one task with three addLabel actions) are required because the policy engine's then blocks don't support conditional logic — per-label not: hasLabel guards can only be expressed at the task level.

Original prompt

Create a new GitOps.PullRequestIssueManagement policy in the PowerShell/PowerShell repository to automatically add backport consideration labels when the CL-BuildPackaging label is added to an open pull request targeting the master branch.

Requirements:

  • Add a new YAML policy file under .github/policies/.
  • Policy trigger/conditions:
    • payloadType: Pull_Request
    • PR is open (isOpen)
    • labelAdded where label is CL-BuildPackaging
    • PR targets branch master using the targetsBranch condition:
      - targetsBranch:
          branch: master
  • Policy actions:
    • Add labels:
      • BackPort-7.4.x-Consider
      • BackPort-7.5.x-Consider
      • BackPort-7.6.x-Consider
    • Include "not guards" so each label is only added if it is not already present.
    • Use the correct predicate name for checking if a label already exists in this policy engine. Search existing policies in this repo under .github/policies/ (and/or other configs) to find the canonical pattern (e.g., labelExists, hasLabel, etc.) and match it.

Implementation notes:

Deliverables:

  • A PR against the master branch adding the new policy file.
  • Ensure YAML formatting and indentation are consistent with repo conventions.

This pull request was created from Copilot chat.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add GitOps PullRequestIssueManagement policy for labels Add GitOps policy to auto-label backport candidates when CL-BuildPackaging is added Feb 23, 2026
Copilot AI requested a review from TravisEz13 February 23, 2026 19:21
@TravisEz13 TravisEz13 marked this pull request as ready for review February 23, 2026 19:51
Copilot AI review requested due to automatic review settings February 23, 2026 19:51
@TravisEz13 TravisEz13 requested a review from a team as a code owner February 23, 2026 19:51
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

This PR adds a new GitOps policy to automatically label open pull requests targeting master with backport consideration labels when the CL-BuildPackaging label is added. This automation helps ensure that build and packaging changes are properly tracked for potential backporting to active release branches (7.4.x, 7.5.x, and 7.6.x).

Changes:

  • Adds a new GitOps.PullRequestIssueManagement policy that triggers on CL-BuildPackaging label addition
  • Implements three separate event responder tasks (one per backport label) to apply BackPort-*-Consider labels
  • Includes duplicate prevention guards using not: hasLabel conditions

@TravisEz13 TravisEz13 added the CL-Tools Indicates that a PR should be marked as a tools change in the Change Log label Feb 23, 2026
@daxian-dbw daxian-dbw merged commit f3eb51b into master Feb 23, 2026
40 of 43 checks passed
@jshigetomi jshigetomi deleted the copilot/add-gitops-pr-issue-management-policy branch April 21, 2026 23:57
JustinGrote pushed a commit to JustinGrote/PowerShell that referenced this pull request Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-Tools Indicates that a PR should be marked as a tools change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants