Skip to content

[all] chore: add validate pr title workflow (#1) #1

[all] chore: add validate pr title workflow (#1)

[all] chore: add validate pr title workflow (#1) #1

name: "Validate PR Title"
on:
pull_request:
types: [ opened, edited, reopened, ready_for_review, synchronize ]
jobs:
validate-pr-title:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Check PR title format
shell: bash
run: |
TITLE="${{ github.event.pull_request.title }}"
echo "PR title: $TITLE"
# Regex for:
# [category/subcategory] type(scope?): description (#123?)
PATTERN='^\[([a-z]+(/[a-z]+)*)\] (feat|fix|chore|docs|style|refactor|perf|test|build|ci|revert)(\([a-z]+\))?: [a-z].*( \(#[0-9]+\))$'
if [[ ! "$TITLE" =~ $PATTERN ]]; then
echo "❌ Invalid PR title."
echo "Required format:"
echo "[category] type(scope?): description (#123)"
exit 1
fi
echo "✅ PR title is valid."