Skip to content

Commit

Permalink
chore: this is how PR templates are supposed to work apparently
Browse files Browse the repository at this point in the history
bonus: new github action that will now auto-label, auto-assign and auto-request review from relevant people 👍
  • Loading branch information
KTrain5169 committed Jul 11, 2024
1 parent b31ed39 commit e6ea010
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/01-add-an-alternative.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: Add an alternative to the list
about: Suggest the inclusion of a new mod that can replace an Essential function.
title: "Add [mod] to the alternatives page."
labels: enhancement
labels: add mod
assignees:
- KTrain5169
- blryface
Expand Down
11 changes: 2 additions & 9 deletions .github/PULL_REQUEST_TEMPLATE/01-add-an-alternative.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
---
name: Adding new alternative
about: Select this if you are adding a new mod to the alternatives page.
title: "add: [mod name] to alternatives page"
labels: enhancement
assignees:
- KTrain5169
- blryface
---
# Alternative addition template
<!-- Use this template if you are adding an alternative to Essential. DO NOT DELETE ABOVE -->

## What part(s) of Essential does this mod replace?

Expand Down
11 changes: 2 additions & 9 deletions .github/PULL_REQUEST_TEMPLATE/02-site-changes.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
---
name: Site changes
about: Select this if you changed the website in a different way.
title: "change/fix (choose one): [short description of the change]"
labels: enhancement
assignees:
- blryface
- WorldWidePixel
---
# Site changes template
<!-- Use this template if changing the site. DO NOT DELETE ABOVE-->

## Are there major changes (ex: signficantly revamping the website visuals) that we NEED to know about?

Expand Down
9 changes: 2 additions & 7 deletions .github/PULL_REQUEST_TEMPLATE/03-chore-stuff.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
---
name: Other stuff that won't affect what people see
about: Select this if you are modifying something that won't affect what other people see on the site.
title: "chore: [short description of changes go here]"
labels: documentation
assignees: KTrain5169
---
# Chore/documentation template
<!-- if you didn't change anything about the website, use this template. DO NOT DELETE THE ABOVE LINE-->

## What have you changed?

Expand Down
4 changes: 4 additions & 0 deletions .github/pull_request_template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pull_request_templates:
- .github/PULL_REQUEST_TEMPLATE/01-add-an-alternative.md
- .github/PULL_REQUEST_TEMPLATE/02-site-changes.md
- .github/PULL_REQUEST_TEMPLATE/03-chore-stuff.md
79 changes: 79 additions & 0 deletions .github/workflows/pr_management.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Auto Label PRs, then add assignees and reviewers automatically.

on:
pull_request:
types: [opened, 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: Label PR based on content
uses: actions/github-script@v6
id: label-pr
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();
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 foundLabels;
- name: Set Reviewers and Assignees
if: steps.label-pr.outputs.result
uses: actions/github-script@v6
with:
script: |
const labelToReviewers = {
'add mod': ['KTrain5169', 'blryface'],
'enhancement': ['WorldWidePixel', 'Nitrrine'],
'documentation': ['blryface', 'KTrain5169', 'WorldWidePixel']
};
const labels = ${{ steps.label-pr.outputs.result }};
const reviewers = new Set();
labels.forEach(label => {
(labelToReviewers[label] || []).forEach(reviewer => reviewers.add(reviewer));
});
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)
});
}
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: 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!

0 comments on commit e6ea010

Please sign in to comment.