-
Notifications
You must be signed in to change notification settings - Fork 78
29 lines (28 loc) · 1.01 KB
/
PRLabelChecker.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
name: Label Checker
on:
pull_request:
branches: dev
types: [opened, labeled, unlabeled, synchronize, reopened]
permissions:
pull-requests: read
contents: read
jobs:
check-labels:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check for specific labels
run: |
PR_NUMBER=$(echo ${{ github.event.pull_request.number }})
LABELS_JSON=$(gh pr view $PR_NUMBER --json labels -q '.labels.[] | .name')
REQUIRED_LABELS=("chore" "ignore" "breaking-change" "enhancement" "feature" "dependencies" "bug" "security" "performance" "refactor" "testing" "documentation" "github-actions")
for REQUIRED_LABEL in "${REQUIRED_LABELS[@]}"; do
if echo "$LABELS_JSON" | grep -q "$REQUIRED_LABEL"; then
echo "One of the required labels is present"
exit 0
fi
done
echo "None of the required labels are present"
exit 1
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}