ci: Release and Changelog automation #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "Validate PR title for Conventional Commits Format" | |
| on: | |
| pull_request: | |
| types: [opened, edited, synchronize, reopened] | |
| jobs: | |
| validate-pr-title-conventional: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check PR title for conventional commits | |
| uses: actions/github-script@v6 | |
| with: | |
| github-token: ${{ github.token }} | |
| script: | | |
| const prTitle = context.payload.pull_request.title; | |
| // Conventional commits regex: type(scope?): description | |
| const conventionalRegex = /^(feat|fix|chore|docs|style|refactor|perf|test|ci)(\([a-z0-9\-]+\))?: .+/; | |
| if (!conventionalRegex.test(prTitle)) { | |
| core.setFailed( | |
| `PR title "${prTitle}" is not in conventional commit format.\n` + | |
| `Example: "feat(android): add new validation function"` | |
| ); | |
| } else { | |
| console.log(`PR title "${prTitle}" follows conventional commit format`); | |
| } |