Skip to content

Commit

Permalink
ci: create semantic pr title GHA (#3783)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-siek committed Nov 17, 2022
1 parent 563e4e9 commit d5c3b91
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/semantic-pr-title.yml
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

0 comments on commit d5c3b91

Please sign in to comment.