Skip to content

Commit cadfcb7

Browse files
committed
chore: Allow dependabot to user lowercase PR titles
1 parent 1a8e934 commit cadfcb7

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

build-packages/check-pr/index.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,18 @@ import { setFailed } from '@actions/core';
22
import { context } from '@actions/github';
33
import { validateTitle, validateBody } from './validators.js';
44

5+
function capitalizeAfterColon(title: string): string {
6+
return title.replace(/^([^:]+:\s*)(\w)/, (_, pre, char) =>
7+
pre + char.toUpperCase()
8+
);
9+
}
10+
511
try {
6-
validateTitle(context.payload.pull_request?.title);
7-
validateBody(context.payload.pull_request?.body?.replace(/\r\n/g, '\n'));
12+
const pr = context.payload.pull_request;
13+
const isDependabot = pr?.user?.login === 'dependabot[bot]';
14+
const title = isDependabot && pr?.title ? capitalizeAfterColon(pr.title) : pr?.title;
15+
validateTitle(title);
16+
validateBody(pr?.body?.replace(/\r\n/g, '\n'));
817
} catch (err: any) {
918
setFailed(err);
1019
}

0 commit comments

Comments
 (0)