chore: update PR title format and validation to include optional scope

This commit is contained in:
Victor Santos
2025-11-27 21:27:29 -03:00
parent 5bf1a62e2e
commit 60daa12d21
2 changed files with 19 additions and 15 deletions

View File

@@ -21,7 +21,7 @@
## Checklist ## Checklist
- [ ] Title follows format: `Type: Short description` (e.g., `Fix: Prevent crash on sync`) - [ ] Title follows format: `type[scope]: Short description` (scope is optional, e.g., `fix: Prevent crash on sync` or `fix[api]: Handle null response`)
- [ ] Tested locally - [ ] Tested locally
- [ ] Updated docs (if needed) - [ ] Updated docs (if needed)
- [ ] Read the [contributing guide](https://infisical.com/docs/contributing/getting-started/overview) - [ ] Read the [contributing guide](https://infisical.com/docs/contributing/getting-started/overview)

View File

@@ -16,11 +16,13 @@ jobs:
const title = context.payload.pull_request.title; const title = context.payload.pull_request.title;
// Valid PR types based on pull_request_template.md // Valid PR types based on pull_request_template.md
const validTypes = ['Fix', 'Feature', 'Improvement', 'Breaking', 'Docs', 'Chore']; const validTypes = ['fix', 'feature', 'improvement', 'breaking', 'docs', 'chore'];
// Regex pattern: Type: Short description // Regex pattern: type[optional-scope]: Short description
// Type must be one of the valid types, followed by colon, space, and description // - Type must be one of the valid types
const pattern = new RegExp(`^(${validTypes.join('|')}): .+$`); // - Scope is optional, must be in brackets, lowercase alphanumeric with hyphens
// - Followed by colon, space, and description
const pattern = new RegExp(`^(${validTypes.join('|')})(\\[[a-z0-9-]+\\])?: .+$`);
if (!pattern.test(title)) { if (!pattern.test(title)) {
const errorMessage = ` const errorMessage = `
@@ -28,20 +30,22 @@ jobs:
Your PR title: \`${title}\` Your PR title: \`${title}\`
**Expected format:** \`Type: Short description\` **Expected format:** \`type[scope]: Short description\`
**Valid types:** **Valid types:**
- \`Fix\` - Bug fixes - \`fix\` - Bug fixes
- \`Feature\` - New features - \`feature\` - New features
- \`Improvement\` - Enhancements to existing features - \`improvement\` - Enhancements to existing features
- \`Breaking\` - Breaking changes - \`breaking\` - Breaking changes
- \`Docs\` - Documentation updates - \`docs\` - Documentation updates
- \`Chore\` - Maintenance tasks - \`chore\` - Maintenance tasks
**Scope:** Optional, short identifier in brackets (e.g., \`[api]\`, \`[auth]\`, \`[ui]\`)
**Examples:** **Examples:**
- \`Fix: Prevent crash on sync\` - \`fix: Prevent crash on sync\`
- \`Feature: Add SSO login support\` - \`fix[api]: Handle null response from auth endpoint\`
- \`Docs: Update API reference\` - \`docs[cli]: Update installation guide\`
`; `;
core.setFailed(errorMessage); core.setFailed(errorMessage);