Setup resource management policy (#2249)

This commit is contained in:
Amaury Levé 2024-02-02 16:19:45 +01:00 коммит произвёл GitHub
Родитель 22cc6a3846
Коммит 4feb0a96fe
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
6 изменённых файлов: 374 добавлений и 101 удалений

36
.github/policies/LabelManagement.IssueClosed.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,36 @@
id:
name: LabelManagement.IssueClosed
description: Handlers when an issue gets closed
owner:
resource: repository
disabled: false
where:
configuration:
resourceManagementConfiguration:
eventResponderTasks:
- description: Remove labels when an issue is closed
if:
- payloadType: Issues
- isAction:
action: Closed
then:
- removeLabel:
label: 'Needs: Triage :mag:'
- removeLabel:
label: 'Needs: Attention :wave:'
- removeLabel:
label: 'Needs: Author Feedback'
- removeLabel:
label: Help-Wanted
- description: Remove labels when a pull request is closed
if:
- payloadType: Pull_Request
- isAction:
action: Closed
then:
- removeLabel:
label: 'Needs: Attention :wave:'
- removeLabel:
label: 'Needs: Author Feedback'
onFailure:
onSuccess:

20
.github/policies/LabelManagement.IssueOpened.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,20 @@
id:
name: LabelManagement.IssueOpened
description: Handlers 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 :mag:'
onFailure:
onSuccess:

144
.github/policies/LabelManagement.IssueUpdated.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,144 @@
id:
name: LabelManagement.IssueUpdated
description: Handlers when an issue is updated but not closed
owner:
resource: repository
disabled: false
where:
configuration:
resourceManagementConfiguration:
eventResponderTasks:
- description: >-
Remove "State: 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: "State: No Recent Activity"
then:
- removeLabel:
label: "State: 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:
- payloadType: Issue_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 :wave:" 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 :wave:"
- description: >-
If team members respond to an issue which needs attention
* Remove the "Needs: Attention :wave:" Label
if:
- or:
- payloadType: Pull_Request_Review
- payloadType: Pull_Request_Review_Comment
- payloadType: Issue_Comment
- isActivitySender:
issueAuthor: True
- hasLabel:
label: "Needs: Attention :wave:"
- not:
isAction:
action: Synchronize
- or:
- activitySenderHasAssociation:
association: Member
- activitySenderHasAssociation:
association: Owner
- activitySenderHasAssociation:
association: Collaborator
then:
- removeLabel:
label: "Needs: Attention :wave:"
- description: >-
If team members respond to an issue which needs attention
* Remove the "Needs: Triage :mag:" Label
if:
- or:
- payloadType: Pull_Request_Review
- payloadType: Pull_Request_Review_Comment
- payloadType: Issue_Comment
- isActivitySender:
issueAuthor: True
- hasLabel:
label: "Needs: Triage :mag:"
- not:
isAction:
action: Synchronize
- or:
- activitySenderHasAssociation:
association: Member
- activitySenderHasAssociation:
association: Owner
- activitySenderHasAssociation:
association: Collaborator
then:
- removeLabel:
label: "Needs: Triage :mag:"
- description: >-
When changes are requested on a pull request
* Disable automerge
* Assign to the author
* Label with "Needs: Author Feedback"
if:
- payloadType: Pull_Request_Review
- isAction:
action: Submitted
- isReviewState:
reviewState: Changes_requested
then:
- disableAutoMerge
- assignTo:
author: True
- addLabel:
label: "Needs: Author Feedback"
- description: Sync labels from issues on all pull request events
if:
- payloadType: Pull_Request
then:
- labelSync:
pattern: "Area:"
- labelSync:
pattern: "Type:"
- inPrLabel:
label: In-PR
onFailure:
onSuccess:

102
.github/policies/ScheduledSearch.AutoClose.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,102 @@
id: ScheduledSearch.AutoClose
name: GitOps.PullRequestIssueManagement
description: Housekeeping of issues that should be closed
owner:
resource: repository
disabled: false
where:
configuration:
resourceManagementConfiguration:
scheduledSearches:
- description: >-
Search for PR where -
* Pull Request is Open
* Pull request has the label "State: No Recent Activity"
* Pull request has the label "Needs: Author Feedback"
* Has not had activity in the last 7 days
Then -
* Close the PR
frequencies:
- hourly:
hour: 6
filters:
- isPullRequest
- isOpen
- hasLabel:
label: "State: No Recent Activity"
- hasLabel:
label: "Needs: Author Feedback"
- noActivitySince:
days: 7
actions:
- closeIssue
- description: >-
Search for Issues where -
* Issue is Open
* Issue has the label "State: No Recent Activity"
* Issue has the label "Needs: Author Feedback"
* Has not had activity in the last 7 days
Then -
* Close the Issue
frequencies:
- hourly:
hour: 6
filters:
- isIssue
- isOpen
- hasLabel:
label: "State: No Recent Activity"
- hasLabel:
label: "Needs: Author Feedback"
- noActivitySince:
days: 7
actions:
- closeIssue
- description: >-
Search for Issues where -
* Issue is Open
* Issue has the label "State: Won't Fix"
* Has not had activity in the last 1 day
Then -
* Close the Issue
frequencies:
- hourly:
hour: 6
filters:
- isIssue
- isOpen
- hasLabel:
label: "State: 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 will be closed for housekeeping purposes.
- closeIssue
- description: >-
Search for Issues where -
* Issue is Open
* Issue has the label "Resolution: Duplicate"
* Has not had activity in the last 1 day
Then -
* Close the Issue
frequencies:
- hourly:
hour: 6
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
onFailure:
onSuccess:

72
.github/policies/ScheduledSearch.MarkNoRecentActivity.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,72 @@
id: ScheduledSearch.MarkNoRecentActivity
name: GitOps.PullRequestIssueManagement
description: Mark issues and pull requests with no recent activity
owner:
resource: repository
disabled: false
where:
configuration:
resourceManagementConfiguration:
scheduledSearches:
- description: >-
Search for PR where -
* Pull Request is Open
* Pull request does not have the label "State: No Recent Activity"
* Pull request has the label "Needs: Author Feedback"
* Has not had activity in the last 7 days
Then -
* Add "State: No Recent Activity" label
* Warn user about pending closure
frequencies:
- hourly:
hour: 6
filters:
- isPullRequest
- isOpen
- isNotLabeledWith:
label: "State: No Recent Activity"
- hasLabel:
label: "Needs: Author Feedback"
- noActivitySince:
days: 7
actions:
- addLabel:
label: "State: No Recent Activity"
- addReply:
reply: >-
Hello @${issueAuthor},
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**.
- description: >-
Search for Issues where -
* Issue is Open
* Issue has the label "Needs: Author Feedback"
* Issue does not have the label "State: No Recent Activity"
* Has not had activity in the last 7 days
Then -
* Add "State: No Recent Activity" label
* Warn user about pending closure
frequencies:
- hourly:
hour: 6
filters:
- isIssue
- isOpen
- hasLabel:
label: "Needs: Author Feedback"
- isNotLabeledWith:
label: "State: No Recent Activity"
- noActivitySince:
days: 7
actions:
- addLabel:
label: "State: No Recent Activity"
- addReply:
reply: >-
Hello @${issueAuthor},
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**.
onFailure:
onSuccess:

101
.github/policies/resourceManagement.yml поставляемый
Просмотреть файл

@ -1,101 +0,0 @@
id:
name: GitOps.PullRequestIssueManagement
description: GitOps.PullRequestIssueManagement primitive
owner:
resource: repository
disabled: false
where:
configuration:
resourceManagementConfiguration:
scheduledSearches:
- description:
frequencies:
- hourly:
hour: 6
filters:
- isIssue
- isOpen
- hasLabel:
label: 'Needs: Author Feedback'
- hasLabel:
label: 'State: No Recent Activity'
- noActivitySince:
days: 10
actions:
- closeIssue
- description:
frequencies:
- hourly:
hour: 6
filters:
- isIssue
- isOpen
- hasLabel:
label: 'Needs: Author Feedback'
- noActivitySince:
days: 4
- isNotLabeledWith:
label: 'State: No Recent Activity'
actions:
- addLabel:
label: 'State: 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 10 days of this comment**.
- description:
frequencies:
- hourly:
hour: 6
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
eventResponderTasks:
- if:
- payloadType: Issue_Comment
- isAction:
action: Created
- isActivitySender:
issueAuthor: True
- hasLabel:
label: 'Needs: Author Feedback'
- isOpen
then:
- addLabel:
label: 'Needs: Attention :wave:'
- removeLabel:
label: 'Needs: Author Feedback'
description:
- if:
- payloadType: Issues
- not:
isAction:
action: Closed
- hasLabel:
label: 'State: No Recent Activity'
then:
- removeLabel:
label: 'State: No Recent Activity'
description:
- if:
- payloadType: Issue_Comment
- hasLabel:
label: 'State: No Recent Activity'
then:
- removeLabel:
label: 'State: No Recent Activity'
description:
- if:
- payloadType: Pull_Request
then:
- inPrLabel:
label: 'State: In-PR'
description:
onFailure:
onSuccess: