Skip to content

Commit 8efc2a5

Browse files
committed
chore: add PR title check workflow
1 parent 6891c04 commit 8efc2a5

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Check Conventional Commit PR Title
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, reopened]
6+
7+
jobs:
8+
check-pr-title:
9+
runs-on: ubuntu-latest
10+
env:
11+
PR_TITLE: ${{ github.event.pull_request.title }}
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
15+
with:
16+
path: amplify-js
17+
- name: Generate Regex and Check PR title
18+
working-directory: ./amplify-js
19+
run: |
20+
regex=$(./scripts/generate-conventional-commit-regex.sh)
21+
if [[ $PR_TITLE =~ $regex ]]; then
22+
echo "✅ PR title '$pr_title' is valid"
23+
exit 0
24+
else
25+
echo "❌ PR title '$pr_title' is invalid"
26+
echo "It should match the pattern: $regex"
27+
exit 1
28+
fi
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
# Get the list of directory names under ./packages
4+
scopes=$(ls -d ./packages/*/ 2>/dev/null | xargs -n 1 basename | tr '\n' '|' | sed 's/|$//')
5+
6+
# If no directories found, set a default scope
7+
if [ -z "$scopes" ]; then
8+
scopes="default"
9+
fi
10+
11+
# Generate the regular expression
12+
regex="^(feat|fix|docs|style|refactor|perf|test|chore|revert|release)(\(($scopes|required)\))?: .+$"
13+
14+
# Output the generated regex
15+
echo "$regex";

0 commit comments

Comments
 (0)