Skip to content

Commit

Permalink
hygeine: Triage policies (#31)
Browse files Browse the repository at this point in the history
* Added resource management policy template

* Add semantic versioning requirement for PRs

* Fix formatting

---------

Co-authored-by: Jared Holgate <jaredholgate@microsoft.com>
  • Loading branch information
oZakari and jaredfholgate authored Sep 4, 2024
1 parent 019d1ed commit 6ae95ca
Show file tree
Hide file tree
Showing 2 changed files with 296 additions and 0 deletions.
279 changes: 279 additions & 0 deletions .github/policies/resourceManagement.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,279 @@
id:
name: GitOps.PullRequestIssueManagement
description: GitOps.PullRequestIssueManagement primitive
owner:
resource: repository
disabled: false
where:
configuration:
resourceManagementConfiguration:
scheduledSearches:
- description:
frequencies:
- hourly:
hour: 3
filters:
- isIssue
- isOpen
- hasLabel:
label: "Needs: Author Feedback :ear:"
- hasLabel:
label: "Status: No Recent Activity :zzz:"
- noActivitySince:
days: 3
actions:
- closeIssue
- description:
frequencies:
- hourly:
hour: 3
filters:
- isIssue
- isOpen
- hasLabel:
label: "Needs: Author Feedback :ear:"
- noActivitySince:
days: 4
- isNotLabeledWith:
label: "Status: No Recent Activity :zzz:"
actions:
- addLabel:
label: "Status: No Recent Activity :zzz:"
- 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:
frequencies:
- hourly:
hour: 3
filters:
- isIssue
- isOpen
- hasLabel:
label: "Type: Duplicate :palms_up_together:"
- 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:
frequencies:
- hourly:
hour: 3
filters:
- isPullRequest
- isOpen
- hasLabel:
label: "Needs: Author Feedback :ear:"
- hasLabel:
label: "Status: No Recent Activity :zzz:"
- noActivitySince:
days: 7
actions:
- closeIssue
- description:
frequencies:
- hourly:
hour: 3
filters:
- isPullRequest
- isOpen
- hasLabel:
label: "Needs: Author Feedback :ear:"
- noActivitySince:
days: 7
- isNotLabeledWith:
label: "Status: No Recent Activity :zzz:"
actions:
- addLabel:
label: "Status: No Recent Activity :zzz:"
- 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:
- if:
- payloadType: Issue_Comment
- isAction:
action: Created
- isActivitySender:
issueAuthor: True
- hasLabel:
label: "Needs: Author Feedback :ear:"
- isOpen
then:
- addLabel:
label: "Needs: Attention :wave:"
- removeLabel:
label: "Needs: Author Feedback :ear:"
description:
- if:
- payloadType: Issues
- not:
isAction:
action: Closed
- hasLabel:
label: "Status: No Recent Activity :zzz:"
then:
- removeLabel:
label: "Status: No Recent Activity :zzz:"
description:
- if:
- payloadType: Issue_Comment
- hasLabel:
label: "Status: No Recent Activity :zzz:"
then:
- removeLabel:
label: "Status: No Recent Activity :zzz:"
description:
- if:
- payloadType: Pull_Request
then:
- inPrLabel:
label: "Status: In PR :point_right:"
description:
- if:
- payloadType: Pull_Request_Review
- isAction:
action: Submitted
- isReviewState:
reviewState: Changes_requested
then:
- addLabel:
label: "Needs: Author Feedback :ear:"
description:
- if:
- payloadType: Pull_Request
- isActivitySender:
issueAuthor: True
- not:
isAction:
action: Closed
- hasLabel:
label: "Needs: Author Feedback :ear:"
then:
- removeLabel:
label: "Needs: Author Feedback :ear:"
description:
- if:
- payloadType: Issue_Comment
- isActivitySender:
issueAuthor: True
- hasLabel:
label: "Needs: Author Feedback :ear:"
then:
- removeLabel:
label: "Needs: Author Feedback :ear:"
description:
- if:
- payloadType: Pull_Request_Review
- isActivitySender:
issueAuthor: True
- hasLabel:
label: "Needs: Author Feedback :ear:"
then:
- removeLabel:
label: "Needs: Author Feedback :ear:"
description:
- if:
- payloadType: Pull_Request
- not:
isAction:
action: Closed
- hasLabel:
label: "Status: No Recent Activity :zzz:"
then:
- removeLabel:
label: "Status: No Recent Activity :zzz:"
description:
- if:
- payloadType: Issue_Comment
- hasLabel:
label: "Status: No Recent Activity :zzz:"
then:
- removeLabel:
label: "Status: No Recent Activity :zzz:"
description:
- if:
- payloadType: Pull_Request_Review
- hasLabel:
label: "Status: No Recent Activity :zzz:"
then:
- removeLabel:
label: "Status: No Recent Activity :zzz:"
description:
- if:
- payloadType: Issue_Comment
then:
- cleanEmailReply
description:
- if:
- payloadType: Pull_Request
- isAction:
action: Opened
- or:
- includesModifiedFiles:
files:
- infra-as-code/bicep/modules/policy/definitions/lib
- includesModifiedFiles:
files:
- infra-as-code/bicep/modules/policy/assignments/lib/policy_assignments
then:
- addReply:
reply: >-
Hey ${issueAuthor}, thanks for creating this PR.
We noticed that this PR is ammending some things related to policies (definitions or assignments) :mag:
Thanks for this however, please keep in mind we replicate all policies from our upstream repo https://github.com/Azure/Enterprise-Scale (via some GitHub Actions) into these Bicep modules.
So it may be that this PR may be closed and we ask you to re-submit the changes to the respective code in our other repo.
However, we will review and advise further anyway but this is just a friendly premptive message and reminder of how policies are used and updated in this repo.
Thanks from your friendly msft-bot.
- addLabel:
label: "Area: Policy"
description:
- if:
- payloadType: Pull_Request
- labelAdded:
label: "Needs: Upstream Policy Changes :arrows_clockwise:"
then:
- addReply:
reply: >-
Hey ${issueAuthor}, thanks for creating this PR.
We noticed that this PR is ammending some things related to policies (definitions or assignments) :mag:
Thanks for this however, please keep in mind we replicate all policies from our upstream repo https://github.com/Azure/Enterprise-Scale (via some GitHub Actions) into these Bicep modules.
We have determined, upon our review, that the changes here are required to be made to the upstream policies in the repo: https://github.com/Azure/Enterprise-Scale
Thanks from the team and our friendly msft-bot.
- closeIssue
description:
- if:
- payloadType: Pull_Request
- hasLabel:
label: "auto-merge :heavy_check_mark:"
then:
- enableAutoMerge:
mergeMethod: Squash
description:
- if:
- payloadType: Pull_Request
- labelRemoved:
label: "auto-merge :heavy_check_mark:"
then:
- disableAutoMerge
description:
onFailure:
onSuccess:
17 changes: 17 additions & 0 deletions .github/workflows/pr-title-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: .Platform - Semantic PR Check

on:
pull_request_target:
types:
- opened
- edited
- synchronize

jobs:
main:
name: Validate PR Title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 6ae95ca

Please sign in to comment.