Skip to content

Commit 48f8eec

Browse files
authored
FDN-4209 Update pr-validator workflow (#34)
1 parent 339a5d3 commit 48f8eec

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

.github/workflows/pr-validator.yml

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: "PR Title and Description Check"
22
on:
33
pull_request:
4-
types: [opened, edited]
4+
types: [opened, edited, synchronize]
55

66
jobs:
77
check-title-and-description:
@@ -14,25 +14,23 @@ jobs:
1414
script: |
1515
const payload = context.payload;
1616
const prTitle = payload.pull_request.title;
17-
const prDescription = payload.pull_request.body;
1817
1918
// The pattern for JIRA ticket format
20-
const jiraPattern = /\b[A-Z]+-\d+\b|breakglass/gi;
19+
// Must be at the beginning of the PR title
20+
// Prefix must be at least 3 uppercase letters
21+
// Excludes tickets with only zeros after the prefix (e.g., XXX-000, XXX-0000)
22+
// Number must be 3 to 6 digits
23+
const jiraPattern = /^[A-Z]{3,}-(?!0+\b)\d{3,6}\b/;
2124
2225
// Check PR title
2326
const hasJiraTitle = jiraPattern.test(prTitle);
2427
console.log(`PR title: ${hasJiraTitle ? 'Valid' : 'Invalid'}`);
2528
26-
// Check PR description
27-
const hasJiraDescription = prDescription ? prDescription.match(jiraPattern) : false;
28-
console.log(`PR description: ${hasJiraDescription ? 'Valid' : 'Invalid'}`);
29-
30-
if (hasJiraTitle || hasJiraDescription) {
31-
console.log('PR title or description format is correct.');
29+
if (hasJiraTitle) {
30+
console.log('PR title format is correct.');
3231
} else {
33-
const errorMessage = [];
34-
errorMessage.push('The PR title and description do not include a valid JIRA ticket!');
35-
console.log(errorMessage.join('\n'));
32+
const errorMessage = 'The PR title must start with a valid JIRA ticket with 3-6 digits (e.g., ABC-123, DATAPLATFORM-12345). The ticket must be at the start, use at least 3 uppercase letters, and the number must not be all zeros.';
33+
console.log(errorMessage);
3634
37-
core.setFailed(errorMessage.join('\n'));
35+
core.setFailed(errorMessage);
3836
}

0 commit comments

Comments
 (0)