Merge pull request #9023 from backstage/blam/goalie-workflows

Remove the awaiting-review label when the PR is closed
This commit is contained in:
Fredrik Adelöw
2022-01-19 11:49:42 +01:00
committed by GitHub
3 changed files with 27 additions and 16 deletions
+24 -7
View File
@@ -1,8 +1,12 @@
# When the target of the PR changes, open, re-open or sync, then re-add the label.
name: Set Awaiting Review
name: 'goalie: update awaiting-review label'
on:
- pull_request_target
pull_request_target:
types:
- opened
- closed
- synchronize
permissions:
issues: write
@@ -21,13 +25,26 @@ jobs:
# TO THE WORKFLOW. THIS SCRIPT WILL AND SHOULD
# RUN FROM THE BASE REPO ALL TIMES.
script: |
// if it's the author, always add awaiting-review label
const isAuthor = context.payload.pull_request.user.login === context.actor
if (isAuthor) {
await github.rest.issues.addLabels({
if (['opened', 'synchronize'].includes(${{ github.event.action }})) {
// if it's the author, always add awaiting-review label
const isAuthor = context.payload.pull_request.user.login === context.actor
if (isAuthor) {
await github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['awaiting-review']
});
}
}
if (${{ github.event.action}} === 'closed') {
await github.rest.issues.removeLabel({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['awaiting-review']
labels: 'awaiting-review'
}).catch((e) => {
console.log(e)
});
}
+1 -1
View File
@@ -1,5 +1,5 @@
# on a review from someone in the reviewers group, remove the awaiting-review label and add the awaiting-author label
name: Goalie Workflow
name: 'goalie: run cron'
on:
schedule:
- cron: '* * * * *'
+2 -8
View File
@@ -91,7 +91,7 @@ module.exports = async ({ github, context, core }) => {
// if all required reviewers have reviewed
if (hasReviewed.size === expectedReviewers.size) {
const recentEventsForPR = await github.paginate(
github.issues.listEvents,
github.rest.issues.listEvents,
{
issue_number: pullRequest.number,
owner: context.repo.owner,
@@ -99,16 +99,10 @@ module.exports = async ({ github, context, core }) => {
},
);
const { data: pr } = await github.pulls.get({
issue_number: pullRequest.number,
owner: context.repo.owner,
repo: context.repo.repo,
});
// if the last event for the issue is not by the author, remove the label
if (
recentEventsForPR[recentEventsForPR.length - 1].actor.login !==
pr.author.login
pullRequest.author.login
) {
await github.rest.issues
.removeLabel({