Skip to content

Commit 59e54d5

Browse files
authored
Merge pull request #21143 from emberjs/kg-pr-lint
2 parents fe5f1fc + 1678be8 commit 59e54d5

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: PR Title Lint
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, reopened, synchronize]
6+
7+
permissions:
8+
contents: read
9+
pull-requests: read
10+
11+
jobs:
12+
lint-pr-title:
13+
name: Lint PR title
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Validate title
17+
uses: actions/github-script@v8
18+
with:
19+
script: |
20+
const title = context.payload.pull_request.title || "";
21+
22+
const bracketedAllowed = [
23+
/^\[BREAKING\]/,
24+
/^\[BUGFIX\]/,
25+
/^\[BUGFIX beta\]/,
26+
/^\[BUGFIX lts\]/,
27+
/^\[BUGFIX release\]/,
28+
/^\[BUGFIX lts-\d+-\d+\]/,
29+
/^\[DOC\]/,
30+
/^\[DOC beta\]/,
31+
/^\[DOC release\]/,
32+
/^\[SECURITY\]/,
33+
/^\[SECURITY CVE-\d+\]/,
34+
/^\[FEATURE [^\]]+\]/,
35+
/^\[CLEANUP\]/
36+
];
37+
38+
const bracketMatch = title.match(/^\[[^\]]+\]/);
39+
if (bracketMatch) {
40+
const ok = bracketedAllowed.some((re) => re.test(title));
41+
if (!ok) {
42+
core.setFailed(
43+
`Invalid bracket tag in PR title: "${bracketMatch[0]}". ` +
44+
"Allowed: [BREAKING], [BUGFIX], [BUGFIX beta], [BUGFIX lts], [BUGFIX release], " +
45+
"[BUGFIX lts-6-8], [DOC], [DOC beta], [DOC release], [SECURITY], [SECURITY CVE-1234], " +
46+
"[FEATURE any-feature-flag-name], [CLEANUP]."
47+
);
48+
}
49+
return;
50+
}
51+
52+
const conventionalMatch = title.match(/^([a-z]+)(\([^)]+\))?:\s/);
53+
if (conventionalMatch) {
54+
core.setFailed(
55+
"Conventional or semantic prefixes are not allowed in PR titles. (ex: `fix:` or `feat:`) " +
56+
"Use an allowed bracket tag or no prefix."
57+
);
58+
}

0 commit comments

Comments
 (0)