-
Notifications
You must be signed in to change notification settings - Fork 1
36 lines (31 loc) · 1.02 KB
/
pr-title.yml
File metadata and controls
36 lines (31 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
name: 02-pr-title-validation
on:
pull_request:
types:
- opened
- edited
- synchronize
- reopened
permissions:
pull-requests: read
jobs:
validate-title:
name: 01-validate-title
runs-on: ubuntu-latest
steps:
- name: 01-validate-pr-title
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
with:
script: |
const title = context.payload.pull_request?.title ?? '';
const conventionalCommitPattern = /^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\([A-Za-z0-9._/-]+\))?!?: .+/;
if (conventionalCommitPattern.test(title)) {
core.info(`PR title is conventional: ${title}`);
return;
}
core.setFailed(
[
'PR title must follow Conventional Commits, e.g. "fix: handle empty docs snapshot" or "feat(cli): add setup command".',
`Received: ${title || '<empty>'}`,
].join('\n')
);