From 8718df12e8204375215324895430c7d169dc4681 Mon Sep 17 00:00:00 2001 From: George Blue Date: Fri, 28 Jun 2024 12:39:28 +0100 Subject: [PATCH] chore: encourage use of Conventional Commits Conventional Commits make release notes easier to read because commits can be sorted by type [#187721512](https://www.pivotaltracker.com/story/show/187721512) --- .github/workflows/conventional-commit.yml | 25 +++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/conventional-commit.yml diff --git a/.github/workflows/conventional-commit.yml b/.github/workflows/conventional-commit.yml new file mode 100644 index 00000000..7b399165 --- /dev/null +++ b/.github/workflows/conventional-commit.yml @@ -0,0 +1,25 @@ +name: Conventional Commit Check + +on: [pull_request] + +jobs: + conventional-commit: + runs-on: ubuntu-latest + steps: + - name: Check + uses: actions/github-script@v7 + with: + script: | + const {data: pr} = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.issue.number, + }) + + const allowed = ["feat\\!", "feat", "fix", "chore", "docs", "build", "test", "revert"] + const re = new RegExp(`^(` + allowed.join('|') + `)(\\(\\w+\\))?: `) + const title = pr['title'] + + if (!re.test(title)) { + throw new Error(`PR title "${title}" does not match conventional commits filter: ${re}`) + }