ci: add PR title validator #4
Workflow file for this run
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: PR Title Check | |
| on: | |
| pull_request: | |
| types: | |
| - opened | |
| - edited | |
| - synchronize | |
| jobs: | |
| check-pr-title: | |
| name: Validate PR Title | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check PR Title Format | |
| run: | | |
| PR_TITLE="${{ github.event.pull_request.title }}" | |
| # Rule 1: PR title must not be empty | |
| if [ -z "$PR_TITLE" ]; then | |
| echo "❌ PR title cannot be empty." | |
| exit 1 | |
| fi | |
| # Rule 2: PR title must follow Conventional Commits format | |
| # Allowed types: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert | |
| PATTERN="^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\(.+\))?: .+" | |
| if ! echo "$PR_TITLE" | grep -Eq "$PATTERN"; then | |
| echo "❌ PR title does not follow the required format." | |
| echo "" | |
| echo "Expected format: <type>: <description>" | |
| echo " or: <type>(scope): <description>" | |
| echo "" | |
| echo "Allowed types: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert" | |
| echo "" | |
| echo "Examples:" | |
| echo " feat: add new block palette" | |
| echo " fix: resolve audio issue" | |
| echo " docs: update contributing guidelines" | |
| echo "" | |
| echo "Your title: \"$PR_TITLE\"" | |
| exit 1 | |
| fi | |
| echo "✅ PR title is valid: \"$PR_TITLE\"" |