-
Notifications
You must be signed in to change notification settings - Fork 134
43 lines (34 loc) · 1.37 KB
/
label-check.yml
File metadata and controls
43 lines (34 loc) · 1.37 KB
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
35
36
37
38
39
40
41
42
43
name: Label Check
on:
pull_request:
types: [opened, reopened, ready_for_review, labeled, unlabeled, synchronize]
permissions: read-all
jobs:
label-check:
if: github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
permissions:
pull-requests: read
steps:
- uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
api.github.com:443
github.com:443
- name: Check for required labels
env:
LABELS: ${{ toJson(github.event.pull_request.labels.*.name) }}
run: |
HAS_BREAKING=$(echo "$LABELS" | jq 'map(select(. == "breaking-change")) | length')
HAS_NON_BREAKING=$(echo "$LABELS" | jq 'map(select(. == "non-breaking-change")) | length')
if [ "$HAS_BREAKING" -gt 0 ] && [ "$HAS_NON_BREAKING" -gt 0 ]; then
echo "::error::PR has both 'breaking-change' and 'non-breaking-change' labels. Please remove one — a change cannot be both."
exit 1
fi
if [ "$HAS_BREAKING" -eq 0 ] && [ "$HAS_NON_BREAKING" -eq 0 ]; then
echo "::error::PR is missing a required label. Please add exactly one of: 'breaking-change' or 'non-breaking-change'."
exit 1
fi
echo "✅ Label check passed."