Skip to content

Commit 2e28b63

Browse files
committed
[all] chore: add validate pr title workflow
1 parent e785540 commit 2e28b63

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: "Validate PR Title"
2+
3+
on:
4+
pull_request:
5+
types: [ opened, edited, reopened, ready_for_review, synchronize ]
6+
7+
jobs:
8+
validate-pr-title:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
pull-requests: write
13+
14+
steps:
15+
- name: Check PR title format
16+
shell: bash
17+
run: |
18+
TITLE="${{ github.event.pull_request.title }}"
19+
echo "PR title: $TITLE"
20+
21+
# Regex for:
22+
# [category/subcategory] type(scope?): description (#123?)
23+
PATTERN='^\[([a-z]+(/[a-z]+)*)\] (feat|fix|chore|docs|style|refactor|perf|test|build|ci|revert)(\([a-z]+\))?: [a-z].*( \(#[0-9]+\))$'
24+
25+
if [[ ! "$TITLE" =~ $PATTERN ]]; then
26+
echo "❌ Invalid PR title."
27+
echo "Required format:"
28+
echo "[category] type(scope?): description (#123)"
29+
exit 1
30+
fi
31+
32+
echo "✅ PR title is valid."

0 commit comments

Comments
 (0)