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
38 changes: 38 additions & 0 deletions .github/workflows/validate-pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
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"

# Skip validation for renovate
if [[ "$TITLE" == *"chore(deps)"* ]]; then
echo "⚠️ Skipping validation for renovate Prs."
exit 0
fi

# 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."