-
Notifications
You must be signed in to change notification settings - Fork 795
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: create semantic pr title GHA (#3783)
- Loading branch information
1 parent
563e4e9
commit d5c3b91
Showing
1 changed file
with
45 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,45 @@ | ||
name: Semantic PR Title | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
- edited | ||
|
||
jobs: | ||
validate: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check PR title | ||
uses: actions/github-script@v6 | ||
env: | ||
TITLE: ${{ github.event.pull_request.title }} | ||
with: | ||
script: | | ||
const { TITLE } = process.env | ||
const types = [ | ||
'feat', | ||
'fix', | ||
'perf', | ||
'style', | ||
'docs', | ||
'refactor', | ||
'test', | ||
'build', | ||
'ci', | ||
'chore', | ||
'Merge', | ||
'Revert', | ||
'Release' | ||
] | ||
console.log('Validating PR title: "%s"', TITLE) | ||
for (const type of types) { | ||
if (TITLE.startsWith(type)) { | ||
console.log('Title matches conventional commits (type: "%s").', type) | ||
return | ||
} | ||
} | ||
const error = new Error('PR title does not follow conventional commits.\n\nPlease refer to https://www.conventionalcommits.org/en/v1.0.0') | ||
error.stack = [] // Clean the error stack, it's useless here. | ||
throw error |