From 5267af6b7e36d2699576ce3559b8d56bbc84904d Mon Sep 17 00:00:00 2001 From: mufazalov Date: Mon, 29 Jul 2024 16:29:01 +0300 Subject: [PATCH] chore: check PR title instead of commits --- .github/workflows/ci.yml | 14 -------------- .github/workflows/pr-title.yml | 27 +++++++++++++++++++++++++++ commitlint.config.js | 7 ++++++- 3 files changed, 33 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/pr-title.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 49b82d5..67ed5c5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,20 +7,6 @@ on: branches: ['**'] jobs: - commitlint: - if: github.event_name == 'pull_request' - name: Commit Naming - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: actions/setup-node@v4 - with: - node-version: 18 - cache: npm - - run: npm ci - - run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose verify_files: name: Verify Files runs-on: ubuntu-latest diff --git a/.github/workflows/pr-title.yml b/.github/workflows/pr-title.yml new file mode 100644 index 0000000..4205112 --- /dev/null +++ b/.github/workflows/pr-title.yml @@ -0,0 +1,27 @@ +name: PR Title + +on: + pull_request: + types: + - opened + - synchronize + - reopened + - edited + +jobs: + verify_title: + name: Verify Title + runs-on: ubuntu-latest + if: ${{github.event.action != 'edited' || github.event.changes.title}} + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 18 + cache: npm + - name: Install Packages + run: npm ci + - name: Run Commitlint + run: echo "${{github.event.pull_request.title}}" | npx commitlint diff --git a/commitlint.config.js b/commitlint.config.js index 3347cb9..efd4ad9 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -1 +1,6 @@ -module.exports = {extends: ['@commitlint/config-conventional']}; +module.exports = { + extends: ['@commitlint/config-conventional'], + rules: { + 'header-max-length': [2, 'always', 72], + }, +};