[all] chore: add validate pr title workflow (#1) #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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." |