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