Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .github/workflows/validate-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: PR Title and Label Validation

on:
pull_request:
types: [opened, edited, synchronize, reopened, labeled, unlabeled]

jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4

- name: Validate PR Title
shell: bash
run: |
PR_TITLE="${{ github.event.pull_request.title }}"
regex='^\[([A-Za-z0-9-]+)\]:\s(\S+)\s(.+)$'
if [[ ! "$PR_TITLE" =~ $regex ]]; then
echo "❌ PR title does not match the required format: [ClickUp Task ID]: [emoji] [Task Name]"
echo "Example: [86c4em56j]: ⛩️ PR Title Validations Workflow or [DEV-1234]: 🧨 Testing"
exit 1
fi

- name: Validate PR Labels
shell: bash
env:
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
REPO: ${{ github.repository }}
run: |
labels=$(gh pr view "$PR_NUMBER" --repo "$REPO" --json labels -q '.labels[].name' | tr '\n' ' ')
echo "Labels: $labels"

fail=0

# Type
if ! echo "$labels" | grep -Eq '\b(feature|fix|refactor|hotfix)\b'; then
echo "❌ Missing Type label (feature, fix, refactor, hotfix)"
fail=1
fi

# Version introduced: accept any x.xx
if ! echo "$labels" | grep -Eq '\b[0-9]+\.[0-9]{2}\b'; then
echo "❌ Missing Version introduced label (e.g. 2.49, 3.07, etc.)"
fail=1
fi

# Stream/Team
if ! echo "$labels" | grep -Eq '\b(rewards|vector|reliability)\b'; then
echo "❌ Missing Stream/Team label (rewards, vector, reliability)"
fail=1
fi

if [ "$fail" -eq 1 ]; then
exit 1
fi

- name: Success
if: ${{ success() }}
run: echo "✅ PR title and labels are valid!"
Loading