From 8fa3453a258cca9450fef9d2b93acf5fd65bdd16 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Mon, 2 Feb 2026 19:15:26 +0100 Subject: [PATCH] chore: optimize the Conventional Commit Linter workflow --- .github/workflows/commitlint.yml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml index 64af26e3..b5d9f922 100644 --- a/.github/workflows/commitlint.yml +++ b/.github/workflows/commitlint.yml @@ -6,11 +6,24 @@ on: - main pull_request: +permissions: + contents: read + jobs: commitlint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 + - name: Compute number of commits to fetch + id: nb-of-commits + # `+ 1` for PRs because of the merge commit + run: | + echo "toParse=$(echo "$EVENT" | jq -r 'if .commits then (.commits | length) else (.pull_request.commits + 1) end')" >> $GITHUB_OUTPUT + env: + EVENT: ${{ toJSON(github.event) }} + - name: Checkout + uses: actions/checkout@v6 with: - fetch-depth: 100 + persist-credentials: false + sparse-checkout: . + fetch-depth: ${{ steps.nb-of-commits.outputs.toParse }} - uses: wagoid/commitlint-github-action@v6