Skip to content

Commit

Permalink
add a check for pr status
Browse files Browse the repository at this point in the history
  • Loading branch information
hugtalbot committed Aug 21, 2023
1 parent 0fb5ddc commit 76b6e5e
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions .github/workflows/label-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
const prNumber = context.payload.pull_request.number;
const labels = context.payload.pull_request.labels.map(label => label.name);
// Array of labels to check for
// Array of possible labels providing a description
const validLabels = ['enhancement', 'deprecated', 'refactoring', 'pr: breaking', 'pr: clean', 'pr: fix', 'pr: new feature', 'pr: test'];
// If no descriptive label is set, add a comment in the PR and make the action check fail
Expand All @@ -38,7 +38,22 @@ jobs:
repo: context.repo.repo,
body: comment
});
core.setFailed('Invalid PR label')
core.setFailed('Invalid descriptive PR label')
}
// Array of possible labels defining the status of the PR
const statusLabels = ['pr: status wip', 'pr: status to review', 'pr: status ready'];
// If no descriptive label is set, add a comment in the PR and make the action check fail
if (!statusLabels.every(label => labels.includes(label))) {
const comment = ':warning: :warning: :warning:<br>@'+context.repo.owner+' your PR does not include any status label :label:<br> Make sure to add one (wip, to review or ready).<br>:warning: :warning: :warning:';
github.issues.createComment({
issue_number: prNumber,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
core.setFailed('Invalid status PR label')
}
// Add all PR labels in log
Expand Down

0 comments on commit 76b6e5e

Please sign in to comment.