Skip to content

Commit 86c4ac4

Browse files
committed
chore: add action to check title prefix
1 parent b640ff2 commit 86c4ac4

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

Diff for: .github/workflows/pr.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: PR
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, synchronize]
6+
7+
jobs:
8+
check-title:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Check PR Title Prefix
12+
uses: actions/github-script@v7
13+
with:
14+
script: |
15+
const titlePrefixes = ['feat', 'fix', 'break', 'chore'];
16+
const title = context.payload.pull_request.title.toLowerCase();
17+
const titleHasValidPrefix = titlePrefixes.some(prefix => title.startsWith(`${prefix}:`));
18+
if (!titleHasValidPrefix) { process.exit(-1); }
19+
20+
- if: failure()
21+
uses: thollander/actions-comment-pull-request@v2
22+
with:
23+
message: |
24+
"🚨 PR title does not meet the requirements. It must start with one of the following prefixes: 'feat:', 'fix:', 'chore:', 'break:'."
25+
comment_tag: PR title check result

0 commit comments

Comments
 (0)