Skip to content

Commit f62b0ca

Browse files
authored
Merge pull request #1577 from asmacdo/enforce-auto-labels
Enforce usage of auto (release) labels
2 parents e87941e + 1d8953e commit f62b0ca

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

.github/workflows/labels.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Check PR Labels
2+
3+
on:
4+
pull_request:
5+
types: [opened, labeled, unlabeled, synchronize]
6+
7+
jobs:
8+
check_labels:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Check PR Labels
12+
uses: actions/github-script@v6
13+
with:
14+
script: |
15+
const allowedPattern = /^(major|minor|patch|performance|internal|documentation|tests|dependencies)$/;
16+
17+
const labels = context.payload.pull_request.labels.map(label => label.name);
18+
19+
const hasValidLabel = labels.some(label => allowedPattern.test(label));
20+
if (!hasValidLabel) {
21+
core.setFailed("The pull request must have a label of 'major', 'minor', or 'patch'.");
22+
} else {
23+
console.log('PR has a valid label.');
24+
}

0 commit comments

Comments
 (0)