Skip to content

Commit 9e23c8c

Browse files
authoredApr 6, 2024··
chore: add action to check PR title prefix (#2836)
1 parent b640ff2 commit 9e23c8c

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
 

‎.github/workflows/pr.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
id: title-check
13+
uses: actions/github-script@v7
14+
with:
15+
script: |
16+
const titlePrefixes = ["feat", "fix", "break", "chore"];
17+
const title = context.payload.pull_request.title.toLowerCase();
18+
const titleHasValidPrefix = titlePrefixes.some((prefix) => title.startsWith(`${prefix}:`));
19+
if (!titleHasValidPrefix) { process.exit(-1); }
20+
21+
- uses: thollander/actions-comment-pull-request@v2
22+
if: success()
23+
with:
24+
message: |
25+
✅ PR title meet the requirements.
26+
comment_tag: PR title check result
27+
28+
- uses: thollander/actions-comment-pull-request@v2
29+
if: failure()
30+
with:
31+
message: |
32+
🚨 PR title does not meet the requirements. It must start with one of the following prefixes: 'feat:', 'fix:', 'chore:', 'break:'.
33+
comment_tag: PR title check result

0 commit comments

Comments
 (0)
Please sign in to comment.