Skip to content

Commit f96ddc4

Browse files
authored
Create pr_checker.yml
1 parent 8a08c16 commit f96ddc4

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

.github/workflows/pr_checker.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: PR Validation
2+
on:
3+
pull_request:
4+
types: [opened, edited, synchronize, labeled, unlabeled, milestoned, demilestoned]
5+
6+
jobs:
7+
validate:
8+
name: Validate PR
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Validate Label
12+
uses: actions/github-script@v6
13+
with:
14+
script: |
15+
const labels = context.payload.pull_request.labels.map(label => label.name);
16+
const requiredRegex = new RegExp('^Type:');
17+
const hasRequiredLabel = labels.some(label => requiredRegex.test(label));
18+
if (!hasRequiredLabel) {
19+
core.setFailed("This PR must have a label starting with 'Type:'.");
20+
}
21+
- name: Validate Description
22+
uses: actions/github-script@v6
23+
with:
24+
script: |
25+
const body = context.payload.pull_request.body;
26+
if (!body) {
27+
core.setFailed(`
28+
The pr is required to have a description.
29+
Provide detail with **what** was changed,
30+
**why** it was changed, and **how** it was changed.
31+
`);
32+
}

0 commit comments

Comments
 (0)