Skip to content

Commit

Permalink
fix!: PR management stuff
Browse files Browse the repository at this point in the history
does this count as breaking? I'm not sure anymore
  • Loading branch information
KTrain5169 committed Jul 13, 2024
1 parent e8575b5 commit 2a38abd
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 135 deletions.
31 changes: 0 additions & 31 deletions .github/PULL_REQUEST_TEMPLATE/01-add-an-alternative.md

This file was deleted.

25 changes: 0 additions & 25 deletions .github/PULL_REQUEST_TEMPLATE/02-site-changes.md

This file was deleted.

19 changes: 0 additions & 19 deletions .github/PULL_REQUEST_TEMPLATE/03-chore-stuff.md

This file was deleted.

58 changes: 58 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Pull request template

## Category

<!-- Make sure the marked category is correct! This is important as your pull request will automatically label your PR and request reviewers!-->

- [ ] Add mod to alternatives page
- [ ] Site changes
- [ ] Chore/documentation updates

## Describe changes

<!-- Describe your changes -->

## Why did you do this?

<!-- If you added a mod to alternatives page, why did you add that mod? -->
<!-- If you made some changes to the site, why and how would this effect the current site? -->
<!-- If you did chore/documentation updates, why so and how will this help? -->

## BREAKING CHANGES

- [ ] Tick this box if you made changes that may or may not break site functionality.

<!-- List breaking changes above this line and why this is necessary. -->

## What issues (if any) would this resolve?

Resolves #x

<!-- add more above if necessary -->

## Checklist

<!-- For adding mods to the alternatives page -->

- [ ] 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.

<!-- For site changes -->

- [ ] 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.

<!-- For chore/doc updates -->

- [ ] I have clearly explained why I have done this.
- [ ] I have searched for duplicate pull requests and have not found any.

<!-- For all -->

- [ ] 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.
6 changes: 6 additions & 0 deletions .github/assign_label_reviewers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
assign:
add mod: ["KTrain5169", "blryface"]
enhancement: ["WorldWidePixel", "Nitrrine"]
documentation: ["blryface", "KTrain5169", "WorldWidePixel"]
all maintainers required:
["blryface", "WorldWidePixel", "Nitrrine", "KTrain5169"]
16 changes: 16 additions & 0 deletions .github/labels.yml
Original file line number Diff line number Diff line change
@@ -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
104 changes: 44 additions & 60 deletions .github/workflows/pr_management.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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/[email protected]
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 }}"

0 comments on commit 2a38abd

Please sign in to comment.