Skip to content

Commit a91bcd0

Browse files
authored
Create require-label.yml
1 parent 2df6d78 commit a91bcd0

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Require Label
2+
3+
on:
4+
pull_request:
5+
types: [ opened, edited, labeled, unlabeled, synchronize ]
6+
7+
jobs:
8+
check-label:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Check for Label
12+
uses: actions/github-script@v8
13+
with:
14+
github-token: ${{ secrets.GITHUB_TOKEN }}
15+
script: |
16+
const requiredLabels = ['housekeeping', 'enhancement', 'bugfix', 'dependencies'];
17+
const labels = context.payload.pull_request.labels.map(label => label.name);
18+
const hasRequiredLabel = labels.some(label => requiredLabels.includes(label));
19+
if (!hasRequiredLabel) {
20+
core.setFailed(`The PR must have at least one of the following labels: ${requiredLabels.join(', ')}.`);
21+
}

0 commit comments

Comments
 (0)