Skip to content

Commit c2e43a5

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

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

Diff for: .github/workflows/pr.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
19+
if (!titleHasValidPrefix) {
20+
github.rest.issues.createComment({
21+
issue_number: context.payload.pull_request.number,
22+
owner: context.repo.owner,
23+
repo: context.repo.repo,
24+
body: "🚨 PR title does not meet the requirements. It must start with one of the following prefixes: 'feat:', 'fix:', 'chore:', 'break:'."
25+
});
26+
throw new Error(message);
27+
}

0 commit comments

Comments
 (0)