From a68e838126599c51850d1b181bbdbe24c78c095e Mon Sep 17 00:00:00 2001 From: Michele Gerarduzzi Date: Thu, 30 Nov 2023 15:39:13 +0100 Subject: [PATCH] configure commitlint on CI --- .github/workflows/commitlint.yml | 45 ++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/commitlint.yml diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml new file mode 100644 index 00000000..4994666d --- /dev/null +++ b/.github/workflows/commitlint.yml @@ -0,0 +1,45 @@ +name: commitlint + +on: + push: + branches: + - main + pull_request: {} + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} + cancel-in-progress: true + +jobs: + commitlint: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: wyvox/action-setup-pnpm@v3 + name: Install pnpm and node + with: + pnpm-version: 8.5.1 + node-version: 18.x + + - name: Print versions + run: | + git --version + node --version + pnpm --version + + - name: Install commitlint + run: | + pnpm install @commitlint/cli@"$(pnpm show @commitlint/cli version)" + pnpm install @commitlint/config-conventional@"$(pnpm show @commitlint/config-conventional version)" + + - name: Validate current commit (last commit) with commitlint + if: github.event_name == 'push' + run: pnpm commitlint --from HEAD~1 --to HEAD --verbose + + - name: Validate PR commits with commitlint + if: github.event_name == 'pull_request' + run: pnpm commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose