-
Notifications
You must be signed in to change notification settings - Fork 1
34 lines (29 loc) · 1.07 KB
/
semantic-pr-label.yml
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
name: Semantic PR Label
run-name: Validate PR Label ${{ github.sha }} by @${{ github.actor }}
on:
pull_request:
types: [opened, edited, synchronize, reopened, labeled, unlabeled]
permissions:
pull-requests: read
jobs:
main:
name: Semantic PR Label
runs-on: ubuntu-latest
steps:
- name: Check for Required Labels
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const requiredLabels = ["none", "patch", "minor", "major"];
const { data: labels } = await github.rest.issues.listLabelsOnIssue({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const hasRequiredLabel = labels.some(label => requiredLabels.includes(label.name));
if (!hasRequiredLabel) {
core.setFailed(`PR must have one of the following labels: ${requiredLabels.join(", ")}`);
} else {
console.log(`PR has a valid label.`);
}