diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index a8a64e7b4b..d8a20a3d53 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,23 +1,27 @@ -# Description 📣 +## Context - + -## Type ✨ +## Screenshots -- [ ] Bug fix -- [ ] New feature + + +## How to test + + + +## Type + +- [ ] Fix +- [ ] Feature - [ ] Improvement -- [ ] Breaking change -- [ ] Documentation +- [ ] Breaking +- [ ] Docs +- [ ] Chore -# Tests 🛠️ +## Checklist - - -```sh -# Here's some code block to paste some code snippets -``` - ---- - -- [ ] I have read the [contributing guide](https://infisical.com/docs/contributing/getting-started/overview), agreed and acknowledged the [code of conduct](https://infisical.com/docs/contributing/getting-started/code-of-conduct). 📝 \ No newline at end of file +- [ ] Title follows format: `Type: Short description` (e.g., `Fix: Prevent crash on sync`) +- [ ] Tested locally +- [ ] Updated docs (if needed) +- [ ] Read the [contributing guide](https://infisical.com/docs/contributing/getting-started/overview) \ No newline at end of file diff --git a/.github/workflows/validate-pr-title.yml b/.github/workflows/validate-pr-title.yml new file mode 100644 index 0000000000..bb251a547b --- /dev/null +++ b/.github/workflows/validate-pr-title.yml @@ -0,0 +1,51 @@ +name: Validate PR Title + +on: + pull_request: + types: [opened, edited, synchronize, reopened] + +jobs: + validate-pr-title: + name: Validate PR Title Format + runs-on: ubuntu-latest + steps: + - name: Check PR Title Format + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 + with: + script: | + const title = context.payload.pull_request.title; + + // Valid PR types based on pull_request_template.md + 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('|')}): .+$`); + + if (!pattern.test(title)) { + const errorMessage = ` + ❌ **Invalid PR Title Format** + + Your PR title: \`${title}\` + + **Expected format:** \`Type: Short description\` + + **Valid types:** + - \`Fix\` - Bug fixes + - \`Feature\` - New features + - \`Improvement\` - Enhancements to existing features + - \`Breaking\` - Breaking changes + - \`Docs\` - Documentation updates + - \`Chore\` - Maintenance tasks + + **Examples:** + - \`Fix: Prevent crash on sync\` + - \`Feature: Add SSO login support\` + - \`Docs: Update API reference\` + `; + + core.setFailed(errorMessage); + } else { + console.log(`✅ PR title is valid: "${title}"`); + } +