-
Notifications
You must be signed in to change notification settings - Fork 113
Refactor policy bot rules into separate files #663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4d6f6aa
Updating to new App
denelon c365a62
Merge branch 'microsoft:main' into main
denelon ba7d62f
Merge branch 'microsoft:main' into main
denelon c75f560
Refactor policy bot rules into separate files
denelon 9fc47c3
Merge branch 'main' into denelon/policy-bot-refactor
denelon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| id: labelAdded.noRecentActivity | ||
| name: GitOps.PullRequestIssueManagement | ||
| description: Handlers when "No-Recent-Activity" label is added | ||
| owner: | ||
| resource: repository | ||
| disabled: false | ||
| where: | ||
| configuration: | ||
| resourceManagementConfiguration: | ||
| eventResponderTasks: | ||
| - description: >- | ||
| When the label "No-Recent-Activity" is added to an issue | ||
| * Add a reply notifying the issue author of pending closure | ||
| if: | ||
| - payloadType: Issues | ||
| - labelAdded: | ||
| label: No-Recent-Activity | ||
| then: | ||
| - 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 **7 days**. It will be closed if no further activity occurs **within 7 days of this comment**. | ||
| # The policy service should trigger even when the label was added by the policy service | ||
| triggerOnOwnActions: true | ||
| - description: >- | ||
| When the label "No-Recent-Activity" is added to a pull request | ||
| * Add a reply notifying the PR author of pending closure | ||
| if: | ||
| - payloadType: Pull_Request | ||
| - labelAdded: | ||
| label: No-Recent-Activity | ||
| then: | ||
| - 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**. | ||
| # The policy service should trigger even when the label was added by the policy service | ||
| triggerOnOwnActions: true | ||
| onFailure: | ||
| onSuccess: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| id: labelManagement.issueClosed | ||
| name: GitOps.PullRequestIssueManagement | ||
| description: Handlers when an issue or pull request gets closed | ||
| owner: | ||
| resource: repository | ||
| disabled: false | ||
| where: | ||
| configuration: | ||
| resourceManagementConfiguration: | ||
| eventResponderTasks: | ||
| - description: Remove labels when an issue or pull request is closed | ||
| if: | ||
| - or: | ||
| - payloadType: Issues | ||
| - payloadType: Pull_Request | ||
| - isAction: | ||
| action: Closed | ||
| then: | ||
| - removeLabel: | ||
| label: Needs-Triage | ||
| - removeLabel: | ||
| label: Needs-Attention | ||
| - removeLabel: | ||
| label: Needs-Author-Feedback | ||
| - removeLabel: | ||
| label: Help-Wanted | ||
| onFailure: | ||
| onSuccess: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| id: labelManagement.issueOpened | ||
| name: GitOps.PullRequestIssueManagement | ||
| description: Handlers for when an issue is first opened | ||
| owner: | ||
| resource: repository | ||
| disabled: false | ||
| where: | ||
| configuration: | ||
| resourceManagementConfiguration: | ||
| eventResponderTasks: | ||
| - description: Add Needs-Triage to new issues | ||
| if: | ||
| - payloadType: Issues | ||
| - isAction: | ||
| action: Opened | ||
| then: | ||
| - addLabel: | ||
| label: Needs-Triage | ||
| - description: Add CodeFlow link to new PRs | ||
| if: | ||
| - payloadType: Pull_Request | ||
| - isAction: | ||
| action: Opened | ||
| then: | ||
| - addCodeFlowLink | ||
| - description: >- | ||
| Close issues with empty body on open or reopen | ||
| * Close the issue | ||
| * Add Needs-Author-Feedback label | ||
| * Add a reply notifying the author | ||
| 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. " | ||
| onFailure: | ||
| onSuccess: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| id: labelManagement.issueUpdated | ||
| name: GitOps.PullRequestIssueManagement | ||
| description: >- | ||
| Handlers for when an issue is updated and not closed. | ||
| This primarily includes handlers for comments, reviews, and re-runs. | ||
| owner: | ||
| resource: repository | ||
| disabled: false | ||
| where: | ||
| configuration: | ||
| resourceManagementConfiguration: | ||
| eventResponderTasks: | ||
| - description: Remove "No-Recent-Activity" when a pull request or issue is updated | ||
| if: | ||
| - or: | ||
| - payloadType: Pull_Request | ||
| - payloadType: Pull_Request_Review | ||
| - payloadType: Pull_Request_Review_Comment | ||
| - payloadType: Issue_Comment | ||
| - payloadType: Issues | ||
| - not: | ||
| isAction: | ||
| action: Closed | ||
| - hasLabel: | ||
| label: No-Recent-Activity | ||
| then: | ||
| - removeLabel: | ||
| label: No-Recent-Activity | ||
| # The policy service should not trigger itself here, or else the label would be removed immediately after being added | ||
| triggerOnOwnActions: False | ||
| - description: Clean email replies on every comment | ||
| if: | ||
| - or: | ||
| - payloadType: Issue_Comment | ||
| - payloadType: Pull_Request_Review_Comment | ||
| then: | ||
| - cleanEmailReply | ||
| - description: Remove "Help-Wanted" label when an issue goes into PR | ||
| if: | ||
| - payloadType: Issues | ||
| - labelAdded: | ||
| label: In-PR | ||
| - hasLabel: | ||
| label: Help-Wanted | ||
| then: | ||
| - removeLabel: | ||
| label: Help-Wanted | ||
| - description: >- | ||
| If an author responds to an issue which needs author feedback | ||
| * Remove the Needs-Author-Feedback Label | ||
| * Add the Needs-Attention Label | ||
| if: | ||
| - or: | ||
| - payloadType: Pull_Request_Review | ||
| - payloadType: Pull_Request_Review_Comment | ||
| - payloadType: Issue_Comment | ||
| - isActivitySender: | ||
| issueAuthor: True | ||
| - hasLabel: | ||
| label: Needs-Author-Feedback | ||
| - not: | ||
| isAction: | ||
| action: Synchronize | ||
| then: | ||
| - removeLabel: | ||
| label: Needs-Author-Feedback | ||
| - addLabel: | ||
| label: Needs-Attention | ||
| - description: >- | ||
| When changes are requested on a pull request | ||
| * Label with Needs-Author-Feedback | ||
| if: | ||
| - payloadType: Pull_Request_Review | ||
| - isAction: | ||
| action: Submitted | ||
| - isReviewState: | ||
| reviewState: Changes_requested | ||
| then: | ||
| - addLabel: | ||
| label: Needs-Author-Feedback | ||
| - description: Sync labels from issues on all pull request events | ||
| if: | ||
| - payloadType: Pull_Request | ||
| then: | ||
| - labelSync: | ||
| pattern: Issue- | ||
| - labelSync: | ||
| pattern: Area- | ||
| - labelSync: | ||
| pattern: Priority- | ||
| - labelSync: | ||
| pattern: Product- | ||
| - labelSync: | ||
| pattern: Severity- | ||
| - labelSync: | ||
| pattern: Impact- | ||
| - inPrLabel: | ||
| label: In-PR | ||
| onFailure: | ||
| onSuccess: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| id: moderatorTriggers | ||
| name: GitOps.PullRequestIssueManagement | ||
| description: Handlers for moderator comment triggers | ||
| owner: | ||
| resource: repository | ||
| disabled: false | ||
| where: | ||
| configuration: | ||
| resourceManagementConfiguration: | ||
| eventResponderTasks: | ||
| - description: >- | ||
| When a moderator comments with specific trigger patterns | ||
| if: | ||
| - or: | ||
| - payloadType: Issue_Comment | ||
| - payloadType: Pull_Request_Review_Comment | ||
| - or: | ||
| - activitySenderHasPermission: | ||
| permission: Admin | ||
| - activitySenderHasPermission: | ||
| permission: Write | ||
| then: | ||
| # Duplicate of # | ||
| - if: | ||
| - commentContains: | ||
| pattern: '(?in)Duplicate\s+of\s+\#?\s*\d+' | ||
| isRegex: True | ||
| 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. Be sure to add your | ||
| π to that issue. Thanks for your report! | ||
| - closeIssue | ||
| - removeLabel: | ||
| label: Needs-Triage | ||
| - addLabel: | ||
| label: Resolution-Duplicate | ||
| - removeLabel: | ||
| label: Needs-Author-Feedback | ||
| # /feedback | ||
| - if: | ||
| - commentContains: | ||
| pattern: '\/feedback' | ||
| isRegex: True | ||
| then: | ||
| - addReply: | ||
| reply: >- | ||
| Hi there! | ||
|
|
||
|
|
||
| Can you please send us feedback with the Feedback Hub with this issue and paste the link here so we can more easily find your crash information on the back end? | ||
|
|
||
|
|
||
| Thanks! | ||
| - addLabel: | ||
| label: Needs-Author-Feedback | ||
| onFailure: | ||
| onSuccess: |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.