Skip to content

ci: Release and Changelog automation #2

ci: Release and Changelog automation

ci: Release and Changelog automation #2

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`);
}