Skip to content

Commit 2244eb6

Browse files
committed
Added pr label checks
1 parent 003cd72 commit 2244eb6

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

.github/workflows/pr-label-check.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Enforce PR Label
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, unlabeled]
6+
7+
jobs:
8+
check-label:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Check for labels
12+
uses: actions/github-script@v6
13+
with:
14+
script: |
15+
const labels = context.payload.pull_request.labels;
16+
if (labels.length === 0) {
17+
throw new Error('This pull request must have at least one label.');
18+
}
19+
- name: Comment on missing labels
20+
if: failure()
21+
uses: actions/github-script@v6
22+
with:
23+
script: |
24+
github.issues.createComment({
25+
issue_number: context.issue.number,
26+
owner: context.repo.owner,
27+
repo: context.repo.repo,
28+
body: 'This pull request must have at least one label.'
29+
})

0 commit comments

Comments
 (0)