-
-
Notifications
You must be signed in to change notification settings - Fork 667
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add action to check title prefix
- Loading branch information
1 parent
b640ff2
commit c2e43a5
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: PR | ||
|
||
on: | ||
pull_request: | ||
types: [opened, edited, synchronize] | ||
|
||
jobs: | ||
check-title: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check PR Title Prefix | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
const titlePrefixes = ['feat', 'fix', 'break', 'chore']; | ||
const title = context.payload.pull_request.title.toLowerCase(); | ||
const titleHasValidPrefix = titlePrefixes.some(prefix => title.startsWith(`${prefix}:`)); | ||
if (!titleHasValidPrefix) { | ||
github.rest.issues.createComment({ | ||
issue_number: context.payload.pull_request.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: "🚨 PR title does not meet the requirements. It must start with one of the following prefixes: 'feat:', 'fix:', 'chore:', 'break:'." | ||
}); | ||
throw new Error(message); | ||
} |