id: 
name: GitOps.PullRequestIssueManagement
description: GitOps.PullRequestIssueManagement primitive
owner: 
resource: repository
disabled: false
where: 
configuration:
  resourceManagementConfiguration:
    scheduledSearches:
    - description: '"Needs-Author-Feedback" and "No-Recent-Activity" issues are closed after 3 days of inactivity'
      frequencies:
      - hourly:
          hour: 3
      filters:
      - isIssue
      - isOpen
      - hasLabel:
          label: Needs-Author-Feedback
      - hasLabel:
          label: No-Recent-Activity
      - noActivitySince:
          days: 3
      actions:
      - closeIssue
    - description: '"Needs-Author-Feedback" issues are labelled "No-Recent-Activity" after 4 days of inactivity'
      frequencies:
      - hourly:
          hour: 3
      filters:
      - isIssue
      - isOpen
      - hasLabel:
          label: Needs-Author-Feedback
      - noActivitySince:
          days: 4
      - isNotLabeledWith:
          label: No-Recent-Activity
      actions:
      - addLabel:
          label: No-Recent-Activity
      - addReply:
          reply: This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for **4 days**. It will be closed if no further activity occurs **within 3 days of this comment**.
    - description: '"Resolution-Duplicate" issues are closed after 1 day of inactivity'
      frequencies:
      - hourly:
          hour: 3
      filters:
      - isIssue
      - isOpen
      - hasLabel:
          label: Resolution-Duplicate
      - noActivitySince:
          days: 1
      actions:
      - addReply:
          reply: This issue has been marked as duplicate and has not had any activity for **1 day**. It will be closed for housekeeping purposes.
      - closeIssue
    - description: '"Needs-Author-Feedback" and "No-Recent-Activity" PRs are closed after 7 days of inactivity'
      frequencies:
      - hourly:
          hour: 3
      filters:
      - isPullRequest
      - isOpen
      - hasLabel:
          label: Needs-Author-Feedback
      - hasLabel:
          label: No-Recent-Activity
      - noActivitySince:
          days: 7
      actions:
      - closeIssue
    - description: Add "No-Recent-Activity" label to PRs with "Needs-Author-Feedback" label after 7 days of inactivity
      frequencies:
      - hourly:
          hour: 3
      filters:
      - isPullRequest
      - isOpen
      - hasLabel:
          label: Needs-Author-Feedback
      - noActivitySince:
          days: 7
      - isNotLabeledWith:
          label: No-Recent-Activity
      actions:
      - addLabel:
          label: No-Recent-Activity
      - addReply:
          reply: This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for **7 days**. It will be closed if no further activity occurs **within 7 days of this comment**.
    eventResponderTasks:
    - description: Add "Needs-Triage" to new issues
      if:
      - payloadType: Issues
      - or:
        - and:
          - isAction:
              action: Opened
          - not:
              hasLabel:
                label: ⛺ Reserved
      then:
      - addLabel:
          label: Needs-Triage
    - description: Replace "Needs-Author-Feedback" with "Needs-Attention" when author comments
      if:
      - payloadType: Issue_Comment
      - isAction:
          action: Created
      - isActivitySender:
          issueAuthor: True
      - hasLabel:
          label: Needs-Author-Feedback
      then:
      - addLabel:
          label: Needs-Attention
      - removeLabel:
          label: Needs-Author-Feedback
    - description: Remove "No-Recent-Activity" when closing an issue
      if:
      - payloadType: Issues
      - not:
          isAction:
            action: Closed
      - hasLabel:
          label: No-Recent-Activity
      then:
      - removeLabel:
          label: No-Recent-Activity
    - description: Remove "No-Recent-Activity" when someone comments on an issue
      if:
      - payloadType: Issue_Comment
      - hasLabel:
          label: No-Recent-Activity
      then:
      - removeLabel:
          label: No-Recent-Activity
    - description: Add "Needs-Author-Feedback" when changes are requested on a PR
      if:
      - payloadType: Pull_Request_Review
      - isAction:
          action: Submitted
      - isReviewState:
          reviewState: Changes_requested
      then:
      - addLabel:
          label: Needs-Author-Feedback
    - description: Remove "Needs-Author-Feedback" when author performs activity on their PR
      if:
      - payloadType: Pull_Request
      - isActivitySender:
          issueAuthor: True
      - not:
          isAction:
            action: Closed
      - hasLabel:
          label: Needs-Author-Feedback
      then:
      - removeLabel:
          label: Needs-Author-Feedback
    - description: Remove "Needs-Author-Feedback" when author comments on their issue
      if:
      - payloadType: Issue_Comment
      - isActivitySender:
          issueAuthor: True
      - hasLabel:
          label: Needs-Author-Feedback
      then:
      - removeLabel:
          label: Needs-Author-Feedback
    - description: Remove "Needs-Author-Feedback" when the author reviews the PR
      if:
      - payloadType: Pull_Request_Review
      - isActivitySender:
          issueAuthor: True
      - hasLabel:
          label: Needs-Author-Feedback
      then:
      - removeLabel:
          label: Needs-Author-Feedback
    - description: Remove "No-Recent-Activity"" when activity occurs on the PR (aside from closing it)
      if:
      - payloadType: Pull_Request
      - not:
          isAction:
            action: Closed
      - hasLabel:
          label: No-Recent-Activity
      then:
      - removeLabel:
          label: No-Recent-Activity
    - description: Remove "No-Recent-Activity" when someone comments on the PR
      if:
      - payloadType: Issue_Comment
      - hasLabel:
          label: No-Recent-Activity
      then:
      - removeLabel:
          label: No-Recent-Activity
    - description: Remove "No-Recent-Activity" when someone reviews the PR
      if:
      - payloadType: Pull_Request_Review
      - hasLabel:
          label: No-Recent-Activity
      then:
      - removeLabel:
          label: No-Recent-Activity
    - description: Enable auto-merge on PRs with the "AutoMerge" label
      if:
      - payloadType: Pull_Request
      - hasLabel:
          label: AutoMerge
      then:
      - enableAutoMerge:
          mergeMethod: Squash
    - description: Disable auto-merge on PRs when the "AutoMerge" label is removed
      if:
      - payloadType: Pull_Request
      - labelRemoved:
          label: AutoMerge
      then:
      - disableAutoMerge
    - description: Add "Needs-Tag-Fix" label to issues without an Area, Issue, or Product label
      if:
      - payloadType: Issues
      - or:
        - and:
          - isLabeled
          - hasLabel:
              label: Mass-Chaos
        - isOpen
        - isLabeled
      - not:
          hasLabel:
            label: Needs-Tag-Fix
      - or:
        - and:
          - not:
              hasLabel:
                label: Area-Accessibility
          - not:
              hasLabel:
                label: Area-AtlasEngine
          - not:
              hasLabel:
                label: Area-AzureShell
          - not:
              hasLabel:
                label: Area-Build
          - not:
              hasLabel:
                label: Area-Chat
          - not:
              hasLabel:
                label: Area-CmdPal
          - not:
              hasLabel:
                label: Area-CodeHealth
          - not:
              hasLabel:
                label: Area-Commandline
          - not:
              hasLabel:
                label: Area-CookedRead
          - not:
              hasLabel:
                label: Area-DefApp
          - not:
              hasLabel:
                label: Area-Extensibility
          - not:
              hasLabel:
                label: Area-Fonts
          - not:
              hasLabel:
                label: Area-GroupPolicy
          - not:
              hasLabel:
                label: Area-i18n
          - not:
              hasLabel:
                label: Area-Input
          - not:
              hasLabel:
                label: Area-Interaction
          - not:
              hasLabel:
                label: Area-Interop
          - not:
              hasLabel:
                label: Area-Localization
          - not:
              hasLabel:
                label: Area-Output
          - not:
              hasLabel:
                label: Area-Performance
          - not:
              hasLabel:
                label: Area-Portable
          - not:
              hasLabel:
                label: Area-Quality
          - not:
              hasLabel:
                label: Area-Remoting
          - not:
              hasLabel:
                label: Area-Rendering
          - not:
              hasLabel:
                label: Area-Schema
          - not:
              hasLabel:
                label: Area-Server
          - not:
              hasLabel:
                label: Area-Settings
          - not:
              hasLabel:
                label: Area-SettingsUI
          - not:
              hasLabel:
                label: Area-ShellExtension
          - not:
              hasLabel:
                label: Area-Suggestions
          - not:
              hasLabel:
                label: Area-TerminalConnection
          - not:
              hasLabel:
                label: Area-TerminalControl
          - not:
              hasLabel:
                label: Area-Theming
          - not:
              hasLabel:
                label: Area-UserInterface
          - not:
              hasLabel:
                label: Area-VT
          - not:
              hasLabel:
                label: Area-Windowing
          - not:
              hasLabel:
                label: Area-WPFControl
        - and:
          - not:
              hasLabel:
                label: Issue-Bug
          - not:
              hasLabel:
                label: Issue-Docs
          - not:
              hasLabel:
                label: Issue-Feature
          - not:
              hasLabel:
                label: Issue-Question
          - not:
              hasLabel:
                label: Issue-Samples
          - not:
              hasLabel:
                label: Issue-Task
          - not:
              hasLabel:
                label: Issue-Scenario
        - and:
          - not:
              hasLabel:
                label: Product-Cmd.exe
          - not:
              hasLabel:
                label: Product-Colortool
          - not:
              hasLabel:
                label: Product-Conhost
          - not:
              hasLabel:
                label: Product-Conpty
          - not:
              hasLabel:
                label: Product-Meta
          - not:
              hasLabel:
                label: Product-Powershell
          - not:
              hasLabel:
                label: Product-Terminal
          - not:
              hasLabel:
                label: Product-WSL
        - and:
          - not: isOpen
          - and:
            - not:
                hasLabel:
                  label: Resolution-Answered
            - not:
                hasLabel:
                  label: Resolution-By-Design
            - not:
                hasLabel:
                  label: Resolution-Duplicate
            - not:
                hasLabel:
                  label: Resolution-External
            - not:
                hasLabel:
                  label: Resolution-Fix-Available
            - not:
                hasLabel:
                  label: Resolution-Fix-Committed
            - not:
                hasLabel:
                  label: Resolution-Won't-Fix
      - not:
          hasLabel:
            label: Needs-Triage
      - not:
          hasLabel:
            label: Resolution-Duplicate
      - not:
          hasLabel:
            label: ⛺ Reserved
      - not:
          hasLabel:
            label: Tracking-External
      then:
      - addLabel:
          label: Needs-Tag-Fix
    - description: Remove "Needs-Tag-Fix" label when an issue is tagged with an Area, Issue, and Product label
      if:
      - payloadType: Issues
      - and:
        - isLabeled
        - hasLabel:
            label: Needs-Tag-Fix
      - and:
        - or:
          - not:
              hasLabel:
                label: Area-Accessibility
          - not:
              hasLabel:
                label: Area-AtlasEngine
          - not:
              hasLabel:
                label: Area-AzureShell
          - not:
              hasLabel:
                label: Area-Build
          - not:
              hasLabel:
                label: Area-Chat
          - not:
              hasLabel:
                label: Area-CmdPal
          - not:
              hasLabel:
                label: Area-CodeHealth
          - not:
              hasLabel:
                label: Area-Commandline
          - not:
              hasLabel:
                label: Area-CookedRead
          - not:
              hasLabel:
                label: Area-DefApp
          - not:
              hasLabel:
                label: Area-Extensibility
          - not:
              hasLabel:
                label: Area-Fonts
          - not:
              hasLabel:
                label: Area-GroupPolicy
          - not:
              hasLabel:
                label: Area-i18n
          - not:
              hasLabel:
                label: Area-Input
          - not:
              hasLabel:
                label: Area-Interaction
          - not:
              hasLabel:
                label: Area-Interop
          - not:
              hasLabel:
                label: Area-Localization
          - not:
              hasLabel:
                label: Area-Output
          - not:
              hasLabel:
                label: Area-Performance
          - not:
              hasLabel:
                label: Area-Portable
          - not:
              hasLabel:
                label: Area-Quality
          - not:
              hasLabel:
                label: Area-Remoting
          - not:
              hasLabel:
                label: Area-Rendering
          - not:
              hasLabel:
                label: Area-Schema
          - not:
              hasLabel:
                label: Area-Server
          - not:
              hasLabel:
                label: Area-Settings
          - not:
              hasLabel:
                label: Area-SettingsUI
          - not:
              hasLabel:
                label: Area-ShellExtension
          - not:
              hasLabel:
                label: Area-Suggestions
          - not:
              hasLabel:
                label: Area-TerminalConnection
          - not:
              hasLabel:
                label: Area-TerminalControl
          - not:
              hasLabel:
                label: Area-Theming
          - not:
              hasLabel:
                label: Area-UserInterface
          - not:
              hasLabel:
                label: Area-VT
          - not:
              hasLabel:
                label: Area-Windowing
          - not:
              hasLabel:
                label: Area-WPFControl
        - or:
          - hasLabel:
              label: Issue-Bug
          - hasLabel:
              label: Issue-Docs
          - hasLabel:
              label: Issue-Feature
          - hasLabel:
              label: Issue-Question
          - hasLabel:
              label: Issue-Samples
          - hasLabel:
              label: Issue-Task
          - hasLabel:
              label: Issue-Scenario
        - or:
          - hasLabel:
              label: Product-Cmd.exe
          - hasLabel:
              label: Product-Colortool
          - hasLabel:
              label: Product-Conhost
          - hasLabel:
              label: Product-Conpty
          - hasLabel:
              label: Product-Meta
          - hasLabel:
              label: Product-Powershell
          - hasLabel:
              label: Product-Terminal
          - hasLabel:
              label: Product-WSL
        - or:
          - isOpen
          - and:
            - not: isOpen
            - or:
              - hasLabel:
                  label: Resolution-Answered
              - hasLabel:
                  label: Resolution-By-Design
              - hasLabel:
                  label: Resolution-Duplicate
              - hasLabel:
                  label: Resolution-External
              - hasLabel:
                  label: Resolution-Fix-Available
              - hasLabel:
                  label: Resolution-Fix-Committed
              - hasLabel:
                  label: Resolution-Won't-Fix
              - hasLabel:
                  label: Tracking-External
      then:
      - removeLabel:
          label: Needs-Tag-Fix
    - description: Add "In-PR" label to issues that are referenced in a PR
      if:
      - payloadType: Pull_Request
      then:
      - inPrLabel:
          label: In-PR
    - description: Remove "Needs-Tag-Fix" label when an issue also has the "Resolution-Duplicate" label
      if:
      - payloadType: Issues
      - hasLabel:
          label: Needs-Tag-Fix
      - hasLabel:
          label: Resolution-Duplicate
      then:
      - removeLabel:
          label: Needs-Tag-Fix
    - description: Close issues that are opened and have the template title
      if:
      - payloadType: Issues
      - or:
        - titleContains:
            pattern: ^\s*Bug Report \(IF I DO NOT CHANGE THIS THE ISSUE WILL BE AUTO-CLOSED\)\s*$
            isRegex: True
        - titleContains:
            pattern: ^\s*Bug Report\s*$
            isRegex: True
      - or:
        - isAction:
            action: Opened
        - isAction:
            action: Reopened
      - not:
          activitySenderHasPermission:
            permission: Write
      - not:
          activitySenderHasPermission:
            permission: Admin
      then:
      - closeIssue
      - addLabel:
          label: Needs-Author-Feedback
      - addReply:
          reply: Hi! Thanks for attempting to open an issue. Unfortunately, your title wasn't changed from the original template which makes it very hard for us to track and triage. You are welcome to fix up the title and try again with a new issue.
    - description: Close issues that are opened and have no body
      if:
      - payloadType: Issues
      - or:
        - isAction:
            action: Opened
        - isAction:
            action: Reopened
      - or:
        - not:
            bodyContains:
              pattern: .+
              isRegex: True
      then:
      - closeIssue
      - addLabel:
          label: Needs-Author-Feedback
      - addReply:
          reply: "Hi! Thanks for attempting to open an issue. Unfortunately, you didn't write anything in the body which makes it impossible to understand your concern. You are welcome to fix up the issue and try again by opening another issue with the body filled out. "
    - description: Request a review from the team when a PR is labeled "Needs-Second"
      if:
      - payloadType: Pull_Request
      - isLabeled
      - hasLabel:
          label: Needs-Second
      - isOpen
      then:
      - requestReview:
          reviewer: zadjii-msft
      - requestReview:
          reviewer: PankajBhojwani
      - requestReview:
          reviewer: carlos-zamora
      - requestReview:
          reviewer: dhowett
      - requestReview:
          reviewer: lhecker
    - description: Remove "Needs-Second" label when a PR is reviewed
      if:
      - payloadType: Pull_Request_Review
      - not: isOpen
      - hasLabel:
          label: Needs-Second
      then:
      - removeLabel:
          label: Needs-Second
    - description: Remove "Help-Wanted" label from issues that are in a PR
      if:
      - payloadType: Issues
      - hasLabel:
          label: In-PR
      - hasLabel:
          label: Help Wanted
      - isLabeled
      then:
      - removeLabel:
          label: Help-Wanted
    - description: Comments with "/dup", "/dupe", or "/duplicate" will close the issue as a duplicate and remove "Needs-" labels
      if:
      - payloadType: Issue_Comment
      - commentContains:
          pattern: '\/dup(licate|e)?(\s+of)?\s+\#[\d]+'
          isRegex: True
      - or:
        - activitySenderHasPermission:
            permission: Admin
        - activitySenderHasPermission:
            permission: Write
      then:
      - addReply:
          reply: Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!
      - closeIssue
      - removeLabel:
          label: Needs-Triage
      - addLabel:
          label: Resolution-Duplicate
      - removeLabel:
          label: Needs-Tag-Fix
      - removeLabel:
          label: Needs-Attention
      - removeLabel:
          label: Needs-Author-Feedback
      - removeLabel:
          label: Needs-Repro
      - removeLabel:
          label: Needs-Second
    - description: Comments with "/feedback" will direct people to Feedback Hub
      if:
      - payloadType: Issue_Comment
      - commentContains:
          pattern: '\/feedback'
          isRegex: True
      - or:
        - activitySenderHasPermission:
            permission: Admin
        - activitySenderHasPermission:
            permission: Write
      then:
      - addReply:
          reply: >2-

            Hi there!<br><br>Can you please send us feedback with the [Feedback Hub](https://support.microsoft.com/en-us/windows/send-feedback-to-microsoft-with-the-feedback-hub-app-f59187f8-8739-22d6-ba93-f66612949332) with this issue? Make sure to click the "Start recording" button, then reproduce the issue before submitting the feedback. Once it's submitted, paste the link here so we can more easily find your crash information on the back end?<br><br>Thanks!<br><br>![image](https://user-images.githubusercontent.com/18356694/140811502-a068f78b-89d2-4587-925a-73e19652b830.png)<br><br>![image](https://user-images.githubusercontent.com/18356694/140811557-cdc22a0f-fa6a-4f6a-953e-73b51f5548a3.png)<br><br>![image](https://user-images.githubusercontent.com/18221333/62478649-6de55400-b760-11e9-806e-5aab7e085a9f.png)
      - addLabel:
          label: Needs-Author-Feedback
    - description: Comments clean the email reply
      if:
      - payloadType: Issue_Comment
      then:
      - cleanEmailReply
    - description: Sync labels when a PR event occurs
      if:
      - payloadType: Pull_Request
      then:
      - labelSync:
          pattern: Issue-
      - labelSync:
          pattern: Area-
      - labelSync:
          pattern: Priority-
      - labelSync:
          pattern: Product-
      - labelSync:
          pattern: Severity-
      - labelSync:
          pattern: Impact-
    - description: Comments with "/dup", "/dupe", or "/duplicate" targeting another repo will close the issue as a duplicate and remove "Needs-" labels
      if:
      - payloadType: Issue_Comment
      - commentContains:
          pattern: '\/dup(licate|e)?(\s+of)?\s+https'
          isRegex: True
      - or:
        - activitySenderHasPermission:
            permission: Admin
        - activitySenderHasPermission:
            permission: Write
      then:
      - addReply:
          reply: Hi! We've identified this issue as a duplicate of one that exists on somebody else's Issue Tracker. Please make sure you subscribe to the referenced external issue for future updates. Thanks for your report!
      - closeIssue
      - removeLabel:
          label: Needs-Triage
      - addLabel:
          label: Resolution-External
      - removeLabel:
          label: Needs-Attention
      - removeLabel:
          label: Needs-Author-Feedback
      - removeLabel:
          label: Needs-Bisect
      - removeLabel:
          label: Needs-Repro
      - removeLabel:
          label: Needs-Second
    - description: Comments with "/?" will replace the "Needs-Attention" label with "Needs-Author-Feedback"
      if:
      - payloadType: Issue_Comment
      - commentContains:
          pattern: /?
          isRegex: False
      - or:
        - activitySenderHasPermission:
            permission: Admin
        - activitySenderHasPermission:
            permission: Write
      then:
      - removeLabel:
          label: Needs-Attention
      - addLabel:
          label: Needs-Author-Feedback
onFailure: 
onSuccess: 
