Skip to content

Commit 282e06e

Browse files
committed
ci: add semantic PR label workflow
1 parent 7029e2e commit 282e06e

File tree

3 files changed

+34
-63
lines changed

3 files changed

+34
-63
lines changed

.github/workflows/changelog.yml

Lines changed: 0 additions & 44 deletions
This file was deleted.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Semantic PR Label
2+
run-name: Validate PR Label ${{ github.sha }} by @${{ github.actor }}
3+
4+
on:
5+
pull_request:
6+
types: [opened, edited, synchronize, reopened, labeled, unlabeled]
7+
8+
permissions:
9+
pull-requests: read
10+
11+
jobs:
12+
main:
13+
name: Semantic PR Label
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Check for Required Labels
17+
uses: actions/github-script@v7
18+
with:
19+
github-token: ${{ secrets.GITHUB_TOKEN }}
20+
script: |
21+
const requiredLabels = ["none", "patch", "minor", "major"];
22+
const { data: labels } = await github.rest.issues.listLabelsOnIssue({
23+
owner: context.repo.owner,
24+
repo: context.repo.repo,
25+
issue_number: context.issue.number,
26+
});
27+
28+
const hasRequiredLabel = labels.some(label => requiredLabels.includes(label.name));
29+
30+
if (!hasRequiredLabel) {
31+
core.setFailed(`PR must have one of the following labels: ${requiredLabels.join(", ")}`);
32+
} else {
33+
console.log(`PR has a valid label.`);
34+
}

.github/workflows/semantic-pr-title.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)