-
-
Notifications
You must be signed in to change notification settings - Fork 0
37 lines (32 loc) · 1.32 KB
/
pullRequestAudit.yml
File metadata and controls
37 lines (32 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
name: Pull Request Auditor
on:
pull_request:
types:
- opened
- labeled
- unlabeled
- edited
- synchronize
- ready_for_review
permissions:
contents: read
jobs:
Label-Auditor:
name: Label Auditor
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
with:
script: |
const categoriesRequiringSemanticVersion = ['feat', 'bug'];
const requiredCategories = ['feat', 'bug', 'doc', 'test', 'dependencies', 'meta', 'security', 'preview'];
const semanticVersions = ['MAJOR', 'MINOR', 'PATCH'];
const labels = context.payload.pull_request.labels;
if (labels.filter(label => requiredCategories.includes(label.name)).length == 0) {
throw new Error(`Pull Request requires one of the following labels: ${requiredCategories.join(', ')}`);
}
if (labels.filter(label => categoriesRequiringSemanticVersion.includes(label.name)).length > 0) {
if (labels.filter(label => semanticVersions.includes(label.name)).length == 0) {
throw new Error(`Pull Request requires a 'Semantic version'-label for the following labels: ${categoriesRequiringSemanticVersion.join(', ')}`);
}
}