name: PR Label Check
on:
pull_request:
types: [opened, labeled, unlabeled, synchronize]
permissions:
pull-requests: read
jobs:
label-check:
name: Validate PR Labels
runs-on: ubuntu-latest
steps:
- name: Check for labels
env:
PR_LABELS: ${{ toJSON(github.event.pull_request.labels.*.name) }}
run: |
# Check if PR has valid labels
if [[ "$PR_LABELS" == "[]" ]]; then
echo "::error::Please select a label for this PR (under Labels)"
echo ""
echo "Please assign the PR a label. Commonly used labels:"
echo " • enhancement"
echo " • bug"
echo " • devops"
echo " • documentation"
echo ""
echo "Labels help organize PRs for review."
exit 1
fi