From 2a38abda557305cc600055dc879759b48af1c5bd Mon Sep 17 00:00:00 2001 From: KTrain5369 <69028025+KTrain5169@users.noreply.github.com> Date: Sat, 13 Jul 2024 18:31:33 +1000 Subject: [PATCH] fix!: PR management stuff does this count as breaking? I'm not sure anymore --- .../01-add-an-alternative.md | 31 ------ .../PULL_REQUEST_TEMPLATE/02-site-changes.md | 25 ----- .../PULL_REQUEST_TEMPLATE/03-chore-stuff.md | 19 ---- .../pull_request_template.md | 58 ++++++++++ .github/assign_label_reviewers.yml | 6 + .github/labels.yml | 16 +++ .github/workflows/pr_management.yml | 104 ++++++++---------- 7 files changed, 124 insertions(+), 135 deletions(-) delete mode 100644 .github/PULL_REQUEST_TEMPLATE/01-add-an-alternative.md delete mode 100644 .github/PULL_REQUEST_TEMPLATE/02-site-changes.md delete mode 100644 .github/PULL_REQUEST_TEMPLATE/03-chore-stuff.md create mode 100644 .github/PULL_REQUEST_TEMPLATE/pull_request_template.md create mode 100644 .github/assign_label_reviewers.yml create mode 100644 .github/labels.yml diff --git a/.github/PULL_REQUEST_TEMPLATE/01-add-an-alternative.md b/.github/PULL_REQUEST_TEMPLATE/01-add-an-alternative.md deleted file mode 100644 index 9aa8e6e..0000000 --- a/.github/PULL_REQUEST_TEMPLATE/01-add-an-alternative.md +++ /dev/null @@ -1,31 +0,0 @@ -# Alternative addition template - - - -## What part(s) of Essential does this mod replace? - -(ex: account switcher, world hosting, etc...) - -## Why should this mod be added? - -(insert detailed and not-at-all effortless explanation here) - -## What issues (if any) would this resolve? - -Resolves #x -(add more if necessary) - -## Any other details we should know? - -(insert notes if necessary) - -## Checklist - -- [ ] I have put clear & concise details about the mod onto the page. -- [ ] The link I have put in is a valid link. -- [ ] This mod is not a RAT. -- [ ] I have searched for duplicate pull requests and have not found any. -- [ ] I did not read this section. - -Vercel will begin deploying to the Preview environment shortly after submitting this pull request. You may click on the "Visit Preview" link below to see a preview of what it would look like. -You may also use the StackBlitz Codeflow button to view the PR in the browser and make changes at the same time if necessary. diff --git a/.github/PULL_REQUEST_TEMPLATE/02-site-changes.md b/.github/PULL_REQUEST_TEMPLATE/02-site-changes.md deleted file mode 100644 index 4e507ce..0000000 --- a/.github/PULL_REQUEST_TEMPLATE/02-site-changes.md +++ /dev/null @@ -1,25 +0,0 @@ -# Site changes template - - - -## Are there major changes (ex: signficantly revamping the website visuals) that we NEED to know about? - -(state major changes if necessary. If there isn't any, just say "No significant changes are included in this pull request.") - -## State your change here - -(insert details of the change) - -### Why is it necessary? - -(explain) - -## Checklist - -- [ ] I have clearly stated why I want this to be changed. -- [ ] For major changes, I have clearly stated what they are and why I've done them. -- [ ] I have searched for duplicate pull requests and have not found any. -- [ ] I did not read this section. - -Vercel will begin deploying to the Preview environment shortly after submitting this pull request. You may click on the "Visit Preview" link below to see a preview of what it would look like. -You may also use the StackBlitz Codeflow button to view the PR in the browser and make changes at the same time if necessary. diff --git a/.github/PULL_REQUEST_TEMPLATE/03-chore-stuff.md b/.github/PULL_REQUEST_TEMPLATE/03-chore-stuff.md deleted file mode 100644 index 43c9dee..0000000 --- a/.github/PULL_REQUEST_TEMPLATE/03-chore-stuff.md +++ /dev/null @@ -1,19 +0,0 @@ -# Chore/documentation template - - - -## What have you changed? - -(ex: PR templates, README, etc...) - -## Why have you done so? - -(explain) - -## Checklist - -- [ ] I have clearly explained why I have done this. -- [ ] I have searched for duplicate pull requests and have not found any. -- [ ] I did not read this section. - -Ignore the notifications below about Vercel deploying to Preview, as this shouldn't be changing what other people will see on the site. diff --git a/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md new file mode 100644 index 0000000..d14976a --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md @@ -0,0 +1,58 @@ +# Pull request template + +## Category + + + +- [ ] Add mod to alternatives page +- [ ] Site changes +- [ ] Chore/documentation updates + +## Describe changes + + + +## Why did you do this? + + + + + +## BREAKING CHANGES + +- [ ] Tick this box if you made changes that may or may not break site functionality. + + + +## What issues (if any) would this resolve? + +Resolves #x + + + +## Checklist + + + +- [ ] I have put clear & concise details about the mod onto the page. +- [ ] The link I have put in is a valid link. +- [ ] This mod is not a RAT. +- [ ] I have searched for duplicate pull requests and have not found any. + + + +- [ ] I have clearly stated why I want this to be changed. +- [ ] For major changes, I have clearly stated what they are and why I've done them. +- [ ] I have searched for duplicate pull requests and have not found any. + + + +- [ ] I have clearly explained why I have done this. +- [ ] I have searched for duplicate pull requests and have not found any. + + + +- [ ] I did not read this section. + +Vercel will begin deploying to the Preview environment shortly after submitting this pull request (unless your only modified directories are listed in `.vercelignore`). You may click on the "Visit Preview" link below to see a preview of what your changes look like. +You may also use the StackBlitz Codeflow button to view the PR in the browser and make changes at the same time if necessary. diff --git a/.github/assign_label_reviewers.yml b/.github/assign_label_reviewers.yml new file mode 100644 index 0000000..9d8044f --- /dev/null +++ b/.github/assign_label_reviewers.yml @@ -0,0 +1,6 @@ +assign: + add mod: ["KTrain5169", "blryface"] + enhancement: ["WorldWidePixel", "Nitrrine"] + documentation: ["blryface", "KTrain5169", "WorldWidePixel"] + all maintainers required: + ["blryface", "WorldWidePixel", "Nitrrine", "KTrain5169"] diff --git a/.github/labels.yml b/.github/labels.yml new file mode 100644 index 0000000..b56bbcd --- /dev/null +++ b/.github/labels.yml @@ -0,0 +1,16 @@ +labels: + - name: "add mod" + conditions: + - body: "- [x] Add mod to alternatives page" + - name: "enhancement" + conditions: + - body: "- [x] Site changes" + - name: "documentation" + conditions: + - body: "- [x] Chore/documentation updates" + - name: "BREAKING CHANGE" + conditions: + - body: "- [x] Tick this box if you made changes that may or may not break site functionality." + - name: "Merge conflict identified" + conditions: + - mergable: false diff --git a/.github/workflows/pr_management.yml b/.github/workflows/pr_management.yml index f20a60e..9c0957b 100644 --- a/.github/workflows/pr_management.yml +++ b/.github/workflows/pr_management.yml @@ -1,81 +1,65 @@ name: Auto Label PRs, then add assignees and reviewers automatically. on: - pull_request: - types: [opened, edited, synchronize] + pull_request_target: + types: [opened, reopened, edited, synchronize] jobs: add_labels_reviewers_assignees: name: Add labels, then reviewers & assignees runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 + - name: Auto-assign PR author as assignee + if: github.event.action == 'opened' + id: author-assignee + uses: itsOliverBott/assign-pr-author-as-assignee@release + with: + token: ${{ secrets.GITHUB_TOKEN }} - name: Label PR based on content id: label-pr - uses: actions/github-script@v7 + uses: prulloac/configurable-pr-labeler@v1.1.2 with: - script: | - const labels = { - 'alternative addition template': 'add mod', - 'site changes template': 'enhancement', - 'chore/documentation template': 'documentation' - }; - - const body = context.payload.pull_request.body.toLowerCase(); + token: ${{ secrets.GITHUB_TOKEN }} - const foundLabels = Object.entries(labels) - .filter(([keyword]) => body.includes(keyword)) - .map(([, label]) => label); - - if (foundLabels.length > 0) { - await github.issues.addLabels({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.payload.pull_request.number, - labels: foundLabels - }); - } - - return { labels: foundLabels }; + - name: Assign/unassign reviewers + id: assign-reviewers + uses: totallymoney/assign-reviewers-by-labels-action@v1.2.0 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + unassign-if-label-removed: true - - name: Set Reviewers and Assignees - if: steps.label-pr.outputs.labels != '[]' - uses: actions/github-script@v7 + - name: Comment on PRs + uses: dannyskoog/pull-request-comment@v1 + if: steps.assign-reviewers.outputs.assigned_status == 'success' && steps.assign_reviewers.outputs.unassigned_status == 'success' with: - script: | - const labelToReviewers = { - 'add mod': ['KTrain5169', 'blryface'], - 'enhancement': ['WorldWidePixel', 'Nitrrine'], - 'documentation': ['blryface', 'KTrain5169', 'WorldWidePixel'] - }; + message: I've labeled your PR, assigned you and requested/un-requested reviews from the relevant people automatically. If you think I did it wrong, please comment below so one of our maintainers can double-check. Thanks! - const labels = JSON.parse('${{ steps.label-pr.outputs.labels }}').labels; - const reviewers = new Set(); + - name: Assigned/unassigned reviewers success debug log + if: steps.assign-reviewers.outputs.assigned_status == 'success' && steps.assign_reviewers.outputs.unassigned_status == 'success' + run: | + echo "Successfully assigned/unassigned reviewers! Printing more info below..." + echo "If values return null, that means I didn't do anything.\n" - labels.forEach(label => { - (labelToReviewers[label] || []).forEach(reviewer => reviewers.add(reviewer)); - }); + echo "PR I assigned reviewers to: ${{ steps.assign_reviewers.outputs.assigned_url }}" + echo "Commit SHA: ${{ github.sha }}" + echo "I assigned: ${{ steps.reviewer.outputs.assigned_reviewers }}" + echo "Additional info: ${{ steps.assign_reviewers.outputs.assigned_message }}" - if (reviewers.size > 0) { - await github.pulls.requestReviewers({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: context.payload.pull_request.number, - reviewers: Array.from(reviewers) - }); - } + echo "PR I unassigned reviewers to: ${{ steps.assign_reviewers.outputs.unassigned_url }}" + echo "Commit SHA: ${{ github.sha }}" + echo "I unassigned: ${{ steps.reviewer.outputs.unassigned_reviewers }}" + echo "Additional info: ${{ steps.assign_reviewers.outputs.unassigned_message }}" - await github.issues.addAssignees({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.payload.pull_request.number, - assignees: [context.payload.pull_request.user.login] - }); + - name: Assigned/unassigned reviewers failure(?) debug log + if: steps.assign-reviewers.outputs.assigned_status == 'info' && steps.assign_reviewers.outputs.unassigned_status == 'info' + run: | + echo "Uh-oh! I ran into an issue when assigning/unassigning reviewers! Here's some info: \n" - - name: Comment on PRs - uses: dannyskoog/pull-request-comment@v1 - with: - message: I've labeled your PR, assigned you and requested reviews from the relevant people automatically. If you think I did it wrong, please comment below so one of our maintainers can double-check. Thanks! + echo "PR I attempted to assign reviewers to: ${{ steps.assign_reviewers.outputs.assigned_url }}" + echo "Commit SHA: ${{ github.sha }}" + echo "Info: ${{ steps.assign_reviewers.outputs.assigned_message }}" + + echo "PR I unassigned reviewers to: ${{ steps.assign_reviewers.outputs.unassigned_url }}" + echo "Commit SHA: ${{ github.sha }}" + echo "Info: ${{ steps.assign_reviewers.outputs.unassigned_message }}"