-
Notifications
You must be signed in to change notification settings - Fork 162
29 lines (27 loc) · 921 Bytes
/
PRLabelChecker.yml
File metadata and controls
29 lines (27 loc) · 921 Bytes
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
name: Label Checker
on:
pull_request:
branches: main
types: [opened, labeled, unlabeled, synchronize, reopened]
permissions:
pull-requests: read
contents: read
jobs:
check-labels:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Ensure exactly one "kind/*" label is applied
run: |
# Count the number of "kind/*" labels directly from the PR labels
PR_NUMBER=${{ github.event.pull_request.number }}
KIND_LABEL_COUNT=$(gh pr view "$PR_NUMBER" --json labels -q '.labels.[].name' | grep -c '^kind/')
if [[ "$KIND_LABEL_COUNT" -eq 1 ]]; then
echo "✅ Exactly one 'kind/*' label is applied."
exit 0
else
echo "❌ PR must have exactly one 'kind/*' label, but found $KIND_LABEL_COUNT."
exit 1
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}