-
Notifications
You must be signed in to change notification settings - Fork 2
31 lines (29 loc) · 1.03 KB
/
pr-title.yml
File metadata and controls
31 lines (29 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
name: PR Title
on:
pull_request:
branches: [main]
types: [opened, edited, synchronize]
jobs:
conventional-commit:
name: Conventional Commit Title
runs-on: ubuntu-latest
steps:
- name: Validate PR title
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
pattern='^(feat|fix|chore|docs|refactor|test|ci|perf|build|revert)(\(.+\))?(!)?: .+'
if [[ ! "$PR_TITLE" =~ $pattern ]]; then
echo "::error::PR title does not follow Conventional Commits format."
echo ""
echo "Expected: <type>[optional scope][!]: <description>"
echo "Got: $PR_TITLE"
echo ""
echo "Allowed types: feat, fix, chore, docs, refactor, test, ci, perf, build, revert"
echo "Examples:"
echo " feat: add new API endpoint"
echo " fix(parser): handle edge case"
echo " chore!: drop support for Node 18"
exit 1
fi
echo "PR title is valid: $PR_TITLE"