diff --git a/.github/workflows/pr-lint.yml b/.github/workflows/pr-lint.yml new file mode 100644 index 0000000..f891332 --- /dev/null +++ b/.github/workflows/pr-lint.yml @@ -0,0 +1,24 @@ +name: PR Lint + +on: + pull_request: + types: [opened, edited, reopened] + +permissions: {} + +jobs: + lint-title: + runs-on: ${{ github.server_url == 'https://github.com' && 'ubuntu-latest' || 'self-hosted' }} + steps: + - name: Validate PR title follows Conventional Commits + env: + PR_TITLE: ${{ github.event.pull_request.title }} + run: | + pattern='^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(.+\))?!?: .+' + if [[ ! "$PR_TITLE" =~ $pattern ]]; then + echo "::error::PR title \"$PR_TITLE\" does not follow Conventional Commits." + echo "Expected format: (optional scope): " + echo "Allowed types: build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test" + exit 1 + fi + echo "PR title \"$PR_TITLE\" follows Conventional Commits."