diff --git a/.github/workflows/validate-pr-title.yml b/.github/workflows/validate-pr-title.yml new file mode 100644 index 00000000..3d35cbf8 --- /dev/null +++ b/.github/workflows/validate-pr-title.yml @@ -0,0 +1,23 @@ +name: Validate PR Title + +on: + pull_request: + branches: [main] + types: [opened, edited, reopened, synchronize] + +permissions: {} + +jobs: + validate-pr-title: + name: Validate PR Title + runs-on: ubuntu-latest + steps: + - name: Check conventional title + env: + PR_TITLE: ${{ github.event.pull_request.title }} + run: | + pattern='^(build|chore|ci|docs|feat|fix|perf|refactor|release|revert|style|test)(\([^()[:space:]]+\))?!?:[[:space:]][^[:space:]].*$' + if [[ ! "$PR_TITLE" =~ $pattern ]]; then + echo '::error::PR titles must use a supported Conventional Commit type.' + exit 1 + fi