From 6ae95ca2d6a15bbf45d6f679e4bb9d684f4aa841 Mon Sep 17 00:00:00 2001 From: Zach Trocinski <30884663+oZakari@users.noreply.github.com> Date: Wed, 4 Sep 2024 09:05:27 -0500 Subject: [PATCH] hygeine: Triage policies (#31) * Added resource management policy template * Add semantic versioning requirement for PRs * Fix formatting --------- Co-authored-by: Jared Holgate --- .github/policies/resourceManagement.yml | 279 ++++++++++++++++++++++++ .github/workflows/pr-title-check.yml | 17 ++ 2 files changed, 296 insertions(+) create mode 100644 .github/policies/resourceManagement.yml create mode 100644 .github/workflows/pr-title-check.yml diff --git a/.github/policies/resourceManagement.yml b/.github/policies/resourceManagement.yml new file mode 100644 index 0000000..4025de9 --- /dev/null +++ b/.github/policies/resourceManagement.yml @@ -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: diff --git a/.github/workflows/pr-title-check.yml b/.github/workflows/pr-title-check.yml new file mode 100644 index 0000000..8653fa4 --- /dev/null +++ b/.github/workflows/pr-title-check.yml @@ -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 }}