Bot refactoring for easier use and updating (#20805)

This commit is contained in:
Steven Bucher 2023-12-08 12:19:05 -08:00 committed by GitHub
parent 3eda139723
commit a1ef78dbec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 492 additions and 420 deletions

View File

@ -0,0 +1,137 @@
id: CloseResolutionTags
name: GitOps.PullRequestIssueManagement
description: Closing issues with Resolution*
owner:
resource: repository
disabled: false
where:
configuration:
resourceManagementConfiguration:
scheduledSearches:
- description: Close if marked as Resolution-Declined after one day of no activity
frequencies:
- hourly:
hour: 12
filters:
- isIssue
- isOpen
- hasLabel:
label: Resolution-Declined
- noActivitySince:
days: 1
actions:
- addReply:
reply: This issue has been marked as declined and has not had any activity for **1 day**. It has been closed for housekeeping purposes.
- closeIssue
- description: Close if marked as Resolution-By Design after one day of no activity
frequencies:
- hourly:
hour: 12
filters:
- isIssue
- isOpen
- hasLabel:
label: Resolution-By Design
- noActivitySince:
days: 1
actions:
- addReply:
reply: This issue has been marked as by-design and has not had any activity for **1 day**. It has been closed for housekeeping purposes.
- closeIssue
- description: Close if marked as Resolution-Won't Fix after one day of no activity
frequencies:
- hourly:
hour: 12
filters:
- isIssue
- isOpen
- hasLabel:
label: Resolution-Won't Fix
- noActivitySince:
days: 1
actions:
- addReply:
reply: This issue has been marked as won't fix and has not had any activity for **1 day**. It has been closed for housekeeping purposes.
- closeIssue
- description: Close if marked as Resolution-No Activity after seven day of no activity, no reply
frequencies:
- hourly:
hour: 12
filters:
- isOpen
- isIssue
- hasLabel:
label: Resolution-No Activity
- noActivitySince:
days: 7
actions:
- closeIssue
- description: Close if marked as Resolution-Duplicate after one day of no activity
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 has been closed for housekeeping purposes.
- closeIssue
- description: Close if marked as Resolution-External after one day of no activity
frequencies:
- hourly:
hour: 3
filters:
- isIssue
- isOpen
- hasLabel:
label: Resolution-External
- noActivitySince:
days: 1
actions:
- addReply:
reply: This issue has been marked as external and has not had any activity for **1 day**. It has been be closed for housekeeping purposes.
- closeIssue
- description: Close if marked as Resolution-Answered after one day of no activity
frequencies:
- hourly:
hour: 12
filters:
- isIssue
- isOpen
- hasLabel:
label: Resolution-Answered
- noActivitySince:
days: 1
actions:
- addReply:
reply: This issue has been marked as answered and has not had any activity for **1 day**. It has been closed for housekeeping purposes.
- closeIssue
- description: Close if marked as Resolution-Fixed after one day of no activity
frequencies:
- hourly:
hour: 12
filters:
- isIssue
- isOpen
- hasLabel:
label: Resolution-Fixed
- noActivitySince:
days: 1
actions:
- addReply:
reply: This issue has been marked as fixed and has not had any activity for **1 day**. It has been closed for housekeeping purposes.
- closeIssue
onFailure:
onSuccess:

View File

@ -0,0 +1,22 @@
id: IssueManagement.IssueFeedbackForm
name: GitOps.PullRequestIssueManagement
description: Bot to request the feedback for how we are doing in the repo, replies on closed PRs and issues that are NOT labeled with no activity
owner:
resource: repository
disabled: false
where:
configuration:
resourceManagementConfiguration:
eventResponderTasks:
- if:
- not:
hasLabel:
label: Resolution-No Activity
- isAction:
action: Closed
then:
- addReply:
reply: " 📣 Hey @${issueAuthor}, how did we do? We would love to hear your feedback with the link below! 🗣️ \n\n🔗 aka.ms/PSRepoFeedback "
triggerOnOwnActions: true
onFailure:
onSuccess:

View File

@ -0,0 +1,107 @@
id: IssueManagement.ResolveStale
name: GitOps.PullRequestIssueManagement
description: Other issue management rules for closing stale and waiting on author requests
owner:
resource: repository
disabled: false
where:
configuration:
resourceManagementConfiguration:
scheduledSearches:
- description: Close if marked as Waiting on Author and no activity in 7 days
frequencies:
- hourly:
hour: 12
filters:
- isOpen
- isIssue
- hasLabel:
label: Waiting on Author
- noActivitySince:
days: 7
actions:
- addReply:
reply: This issue has been marked as "Waiting on Author" and has not had any activity for **7 day**. It has been closed for housekeeping purposes.
- closeIssue
- description: Label as Resolution-No Activity if not labeled with KeepOpen and no activity in 6 months
frequencies:
- hourly:
hour: 24
filters:
- isIssue
- isOpen
- isNotLabeledWith:
label: KeepOpen
- isNotLabeledWith:
label: Needs-Triage
- isNotLabeledWith:
label: Resolution-No Activity
- isNotLabeledWith:
label: Issue-Meta
- isNotLabeledWith:
label: Review - Needed
- isNotLabeledWith:
label: Review - Committee
- isNotLabeledWith:
label: Review - Maintainer
- isNotLabeledWith:
label: WG-NeedsReview
# Up for grabs labeled issues will get closed after a 6 months of no activity unless KeepOpen label is included
- noActivitySince:
days: 180
actions:
- addLabel:
label: Resolution-No Activity
- addReply:
reply: "This issue has not had any activity in 6 months, if there is no further activity in 7 days, the issue will be closed automatically.\n\nActivity in this case refers only to comments on the issue. If the issue is closed and you are the author, you can re-open the issue using the button below. Please add more information to be considered during retriage. If you are not the author but the issue is impacting you after it has been closed, please submit a new issue with updated details and a link to this issue and the original."
eventResponderTasks:
- description: Remove no resolution label if anyone comments while in 7 day window
if:
- payloadType: Issue_Comment
- hasLabel:
label: Resolution-No Activity
- isOpen
then:
- removeLabel:
label: Resolution-No Activity
- description: If new issue comment is author then remove waiting on author
if:
- payloadType: Issue_Comment
- isActivitySender:
issueAuthor: True
- hasLabel:
label: Waiting on Author
then:
- removeLabel:
label: Waiting on Author
- description: Remove Stale label if issue comment
if:
- payloadType: Issue_Comment
- hasLabel:
label: Stale
then:
- removeLabel:
label: Stale
- description: Remove Needs-Triage label if issue is closed
if:
- payloadType: Issues
- isAction:
action: Closed
then:
- removeLabel:
label: Needs-Triage
- description: Remove Keep Open label if closed by someone
if:
- payloadType: Issues
- isAction:
action: Closed
then:
- removeLabel:
label: KeepOpen
onFailure:
onSuccess:

226
.github/policies/PRManagement.yml vendored Normal file
View File

@ -0,0 +1,226 @@
id: PRManagement
name: GitOps.PullRequestIssueManagement
description: Collection of PR bot triaging behaviors
owner:
resource: repository
disabled: false
where:
configuration:
resourceManagementConfiguration:
scheduledSearches:
- description: If Stale label and waiting on author and no activity since 10 days then close the PR
frequencies:
- hourly:
hour: 12
filters:
- isPullRequest
- isOpen
- hasLabel:
label: Waiting on Author
- hasLabel:
label: Stale
- noActivitySince:
days: 10
actions:
- closeIssue
- description: If PR has Waiting on Author label and no activity in 15 days label as stale.
frequencies:
- hourly:
hour: 3
filters:
- isPullRequest
- isOpen
- hasLabel:
label: Waiting on Author
- noActivitySince:
days: 15
- isNotLabeledWith:
label: Stale
actions:
- addLabel:
label: Stale
- 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 **15 days**. It will be closed if no further activity occurs **within 10 days of this comment**.
- description: Label Review - Needed if PR is opened an no activity in 7 days but no other labels on it
frequencies:
- hourly:
hour: 12
filters:
- isPullRequest
- isOpen
- isNotLabeledWith:
label: Waiting on Author
- noActivitySince:
days: 7
- isNotLabeledWith:
label: Stale
- isNotLabeledWith:
label: Review - Needed
- isNotLabeledWith:
label: Review - Committee
- isNotDraftPullRequest
actions:
- addLabel:
label: Review - Needed
- addReply:
reply: >-
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for **7 days**.
Maintainer, please provide feedback and/or mark it as `Waiting on Author`
- description: Add waiting on Author label if is draft PR, if no activity label
frequencies:
- hourly:
hour: 12
filters:
- isOpen
- isDraftPullRequest
- isNotLabeledWith:
label: Review - Committee
- isNotLabeledWith:
label: Waiting on Author
- isNotLabeledWith:
label: Stale
- noActivitySince:
days: 3
actions:
- addLabel:
label: Waiting on Author
eventResponderTasks:
- description: If PR has AutoMerge Label then enable Automerge to squash
if:
- payloadType: Pull_Request
- hasLabel:
label: AutoMerge
then:
- enableAutoMerge:
mergeMethod: Squash
- description: If PR has label AutoMerge Removed then disable Automerge
if:
- payloadType: Pull_Request
- labelRemoved:
label: AutoMerge
then:
- disableAutoMerge
- description: If PR review requests changes then add label waiting on Author and remove review needed
if:
- payloadType: Pull_Request_Review
- isAction:
action: Submitted
- isReviewState:
reviewState: Changes_requested
then:
- addLabel:
label: Waiting on Author
- removeLabel:
label: Review - Needed
- description: Remove Waiting on author if has label and activity from author
if:
- payloadType: Pull_Request
- isActivitySender:
issueAuthor: True
- not:
isAction:
action: Closed
- hasLabel:
label: Waiting on Author
- not:
titleContains:
pattern: "(WIP|Work in progress|\U0001F6A7)"
isRegex: True
then:
- removeLabel:
label: Waiting on Author
- description: remove waiting on author if review by author and has waiting on author
if:
- payloadType: Pull_Request_Review
- isActivitySender:
issueAuthor: True
- hasLabel:
label: Waiting on Author
then:
- removeLabel:
label: Waiting on Author
- description: Remove Stale label if PR has activity from author which is not closure
if:
- payloadType: Pull_Request
- not:
isAction:
action: Closed
- hasLabel:
label: Stale
- isActivitySender:
issueAuthor: True
then:
- removeLabel:
label: Stale
- description: Remove Stale label if PR is reviewed
if:
- payloadType: Pull_Request_Review
- hasLabel:
label: Stale
then:
- removeLabel:
label: Stale
- description: Remove Review Needed if PR is created or done any action by Admins and iSazonov
if:
- payloadType: Pull_Request
- hasLabel:
label: Review - Needed
- or:
- isAction:
action: Null
- isAction:
action: Closed
- isAction:
action: Reopened
- isAction:
action: Assigned
- isAction:
action: Unassigned
- isAction:
action: Unlabeled
- or:
- activitySenderHasPermission:
permission: Admin
- isActivitySender:
user: iSazonov
issueAuthor: False
then:
- removeLabel:
label: Review - Needed
- description: Remove Review - Needed if issue comment is by admin or iSazonov
if:
- payloadType: Issue_Comment
- hasLabel:
label: Review - Needed
- or:
- activitySenderHasPermission:
permission: Admin
- isActivitySender:
user: iSazonov
issueAuthor: False
then:
- removeLabel:
label: Review - Needed
- description: If inPRLabel then label in PR
if:
- payloadType: Pull_Request
then:
- inPrLabel:
label: In-PR
onFailure:
onSuccess:

View File

@ -1,420 +0,0 @@
id:
name: GitOps.PullRequestIssueManagement
description: GitOps.PullRequestIssueManagement primitive
owner:
resource: repository
disabled: false
where:
configuration:
resourceManagementConfiguration:
scheduledSearches:
- description:
frequencies:
- hourly:
hour: 12
filters:
- isPullRequest
- isOpen
- hasLabel:
label: Waiting on Author
- hasLabel:
label: Stale
- noActivitySince:
days: 10
actions:
- closeIssue
- description:
frequencies:
- hourly:
hour: 3
filters:
- isPullRequest
- isOpen
- hasLabel:
label: Waiting on Author
- noActivitySince:
days: 15
- isNotLabeledWith:
label: Stale
actions:
- addLabel:
label: Stale
- 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 **15 days**. It will be closed if no further activity occurs **within 10 days of this comment**.
- description:
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 has been closed for housekeeping purposes.
- closeIssue
- description:
frequencies:
- hourly:
hour: 3
filters:
- isIssue
- isOpen
- hasLabel:
label: Resolution-External
- noActivitySince:
days: 1
actions:
- addReply:
reply: This issue has been marked as external and has not had any activity for **1 day**. It has been be closed for housekeeping purposes.
- closeIssue
- description:
frequencies:
- hourly:
hour: 12
filters:
- isIssue
- isOpen
- hasLabel:
label: Resolution-Answered
- noActivitySince:
days: 1
actions:
- addReply:
reply: This issue has been marked as answered and has not had any activity for **1 day**. It has been closed for housekeeping purposes.
- closeIssue
- description:
frequencies:
- hourly:
hour: 12
filters:
- isIssue
- isOpen
- hasLabel:
label: Resolution-Fixed
- noActivitySince:
days: 1
actions:
- addReply:
reply: This issue has been marked as fixed and has not had any activity for **1 day**. It has been closed for housekeeping purposes.
- closeIssue
- description:
frequencies:
- hourly:
hour: 12
filters:
- isPullRequest
- isOpen
- isNotLabeledWith:
label: Waiting on Author
- noActivitySince:
days: 7
- isNotLabeledWith:
label: Stale
- isNotLabeledWith:
label: Review - Needed
- isNotLabeledWith:
label: Review - Committee
- isNotDraftPullRequest
actions:
- addLabel:
label: Review - Needed
- addReply:
reply: >-
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for **7 days**.
Maintainer, please provide feedback and/or mark it as `Waiting on Author`
- description:
frequencies:
- hourly:
hour: 12
filters:
- isOpen
- isDraftPullRequest
- isNotLabeledWith:
label: Review - Committee
- isNotLabeledWith:
label: Waiting on Author
- isNotLabeledWith:
label: Stale
- noActivitySince:
days: 3
actions:
- addLabel:
label: Waiting on Author
- description:
frequencies:
- hourly:
hour: 12
filters:
- isIssue
- isOpen
- hasLabel:
label: Resolution-Declined
- noActivitySince:
days: 1
actions:
- addReply:
reply: This issue has been marked as declined and has not had any activity for **1 day**. It has been closed for housekeeping purposes.
- closeIssue
- description:
frequencies:
- hourly:
hour: 12
filters:
- isIssue
- isOpen
- hasLabel:
label: Resolution-By Design
- noActivitySince:
days: 1
actions:
- addReply:
reply: This issue has been marked as by-design and has not had any activity for **1 day**. It has been closed for housekeeping purposes.
- closeIssue
- description:
frequencies:
- hourly:
hour: 12
filters:
- isIssue
- isOpen
- hasLabel:
label: Resolution-Won't Fix
- noActivitySince:
days: 1
actions:
- addReply:
reply: This issue has been marked as won't fix and has not had any activity for **1 day**. It has been closed for housekeeping purposes.
- closeIssue
- description:
frequencies:
- hourly:
hour: 12
filters:
- isOpen
- isIssue
- hasLabel:
label: Waiting on Author
- noActivitySince:
days: 7
actions:
- addReply:
reply: This issue has been marked as "Waiting on Author" and has not had any activity for **7 day**. It has been closed for housekeeping purposes.
- closeIssue
- description: Resolution no activity
frequencies:
- hourly:
hour: 12
filters:
- isOpen
- isIssue
- hasLabel:
label: Resolution-No Activity
- noActivitySince:
days: 7
actions:
- addReply:
reply: This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.
- closeIssue
- description: This is for closing issues that have no activity for 6 months.
frequencies:
- hourly:
hour: 24
filters:
- isIssue
- isOpen
- isNotLabeledWith:
label: KeepOpen
- isNotLabeledWith:
label: Resolution-No Activity
- noActivitySince:
days: 180
actions:
- addReply:
reply: This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
- addLabel:
label: Resolution-No Activity
eventResponderTasks:
- if:
- payloadType: Issue_Comment
- hasLabel:
label: Resolution-No Activity
then:
- removeLabel:
label: Resolution-No Activity
description: Remove resolution no activity label when anyone comments on an issue with the label.
- if:
- payloadType: Pull_Request
- hasLabel:
label: AutoMerge
then:
- enableAutoMerge:
mergeMethod: Squash
description:
- if:
- payloadType: Pull_Request
- labelRemoved:
label: AutoMerge
then:
- disableAutoMerge
description:
- if:
- payloadType: Pull_Request_Review
- isAction:
action: Submitted
- isReviewState:
reviewState: Changes_requested
then:
- addLabel:
label: Waiting on Author
- removeLabel:
label: Review - Needed
description:
- if:
- payloadType: Pull_Request
- isActivitySender:
issueAuthor: True
- not:
isAction:
action: Closed
- hasLabel:
label: Waiting on Author
- not:
titleContains:
pattern: "(WIP|Work in progress|\U0001F6A7)"
isRegex: True
then:
- removeLabel:
label: Waiting on Author
description:
- if:
- payloadType: Issue_Comment
- isActivitySender:
issueAuthor: True
- hasLabel:
label: Waiting on Author
then:
- removeLabel:
label: Waiting on Author
description:
- if:
- payloadType: Pull_Request_Review
- isActivitySender:
issueAuthor: True
- hasLabel:
label: Waiting on Author
then:
- removeLabel:
label: Waiting on Author
- if:
- payloadType: Pull_Request
- not:
isAction:
action: Closed
- hasLabel:
label: Stale
- isActivitySender:
issueAuthor: True
then:
- removeLabel:
label: Stale
description:
- if:
- payloadType: Issue_Comment
- hasLabel:
label: Stale
then:
- removeLabel:
label: Stale
description:
- if:
- payloadType: Pull_Request_Review
- hasLabel:
label: Stale
then:
- removeLabel:
label: Stale
description:
- if:
- payloadType: Issue_Comment
then:
- cleanEmailReply
description:
- if:
- payloadType: Pull_Request
- hasLabel:
label: Review - Needed
- or:
- isAction:
action: Null
- isAction:
action: Closed
- isAction:
action: Reopened
- isAction:
action: Assigned
- isAction:
action: Unassigned
- isAction:
action: Unlabeled
- or:
- activitySenderHasPermission:
permission: Admin
- isActivitySender:
user: iSazonov
issueAuthor: False
then:
- removeLabel:
label: Review - Needed
description:
- if:
- payloadType: Issue_Comment
- hasLabel:
label: Review - Needed
- or:
- activitySenderHasPermission:
permission: Admin
- isActivitySender:
user: iSazonov
issueAuthor: False
then:
- removeLabel:
label: Review - Needed
description:
- if:
- payloadType: Issues
- isAction:
action: Closed
then:
- removeLabel:
label: Needs-Triage
description:
- if:
- payloadType: Pull_Request
then:
- inPrLabel:
label: In-PR
description:
- if:
- payloadType: Issue_Comment
- isActivitySender:
issueAuthor: True
- hasLabel:
label: Waiting on Author
then:
- removeLabel:
label: Waiting on Author
description: Automatically commenting for feedback when an issue is closed
triggerOnOwnActions: true
- if:
- isAction:
action: Closed
then:
- addReply:
reply: " 📣 Hey @${issueAuthor}, how did we do? We would love to hear your feedback with the link below! 🗣️ \n\n🔗 https://forms.office.com/r/P926k48jRJ "
onFailure:
onSuccess: