From 3941db84b24d076fc87fff8aed6e243867244141 Mon Sep 17 00:00:00 2001 From: sapphi-red <49056869+sapphi-red@users.noreply.github.com> Date: Tue, 12 May 2026 17:49:09 +0900 Subject: [PATCH] ci: add PR title linter --- .github/workflows/lint-pr-title.yml | 34 +++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/lint-pr-title.yml diff --git a/.github/workflows/lint-pr-title.yml b/.github/workflows/lint-pr-title.yml new file mode 100644 index 0000000..770a876 --- /dev/null +++ b/.github/workflows/lint-pr-title.yml @@ -0,0 +1,34 @@ +name: Lint PR Title + +permissions: {} + +on: + pull_request: + types: + - opened + - edited + - reopened + +jobs: + lint-pr-title: + name: Validating PR title + runs-on: ubuntu-latest + steps: + - env: + TITLE: ${{ github.event.pull_request.title }} + run: | + PATTERN='^(build|chore|ci|docs|feat|fix|perf|refactor|release|revert|style|test)(\([a-z0-9/_-]+\))?!?: .+' + if ! printf '%s' "$TITLE" | grep -Eq "$PATTERN"; then + { + echo "::error title=Invalid PR title::PR title must follow Conventional Commits." + echo "" + echo "Got: $TITLE" + echo "Expected: (): e.g. fix(parser): handle trailing comma" + echo " : e.g. fix: handle trailing comma" + echo "" + echo "Allowed types: build, chore, ci, docs, feat, fix, perf, refactor, release, revert, style, test" + echo "Scope: optional; chars a-z 0-9 / _ -" + echo "Breaking: append ! before the colon (e.g. feat(ast)!: ... or feat!: ...)" + } >&2 + exit 1 + fi