From a7a5afc3f984397901de3819031d9aa698cfa9f3 Mon Sep 17 00:00:00 2001 From: pqvr Date: Fri, 9 May 2025 11:03:12 -0400 Subject: [PATCH 1/5] chore: move commit lint file --- .github/{commitlint.yml => workflows/commitlint.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{commitlint.yml => workflows/commitlint.yaml} (100%) diff --git a/.github/commitlint.yml b/.github/workflows/commitlint.yaml similarity index 100% rename from .github/commitlint.yml rename to .github/workflows/commitlint.yaml From 34078c8b9455577f3ba213ee92642a2ddd240ee7 Mon Sep 17 00:00:00 2001 From: pqvr Date: Fri, 9 May 2025 13:08:14 -0400 Subject: [PATCH 2/5] fix: attempt to fix broken pipeline --- .github/workflows/commitlint.yaml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/commitlint.yaml b/.github/workflows/commitlint.yaml index d69322fc..e44658d8 100644 --- a/.github/workflows/commitlint.yaml +++ b/.github/workflows/commitlint.yaml @@ -32,8 +32,12 @@ jobs: - name: Lint commits run: | if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then - RANGE="${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }}" + FROM_SHA="${{ github.event.pull_request.base.sha }}" + TO_SHA="${{ github.event.pull_request.head.sha }}" else - RANGE="${{ github.event.before }}...${{ github.sha }}" + FROM_SHA="${{ github.event.before }}" + TO_SHA="${{ github.sha }}" fi - npx commitlint --from "$RANGE" --to "${{ github.sha }}" + + echo "Linting commits from $FROM_SHA to $TO_SHA" + npx commitlint --from "$FROM_SHA" --to "$TO_SHA" From 6cd723657369d28b2dbee763b36f36f3ea6b8597 Mon Sep 17 00:00:00 2001 From: pqvr Date: Mon, 12 May 2025 06:45:14 -0400 Subject: [PATCH 3/5] chore: update to only check title against conventional commit --- .github/workflows/commitlint.yaml | 43 ------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 .github/workflows/commitlint.yaml diff --git a/.github/workflows/commitlint.yaml b/.github/workflows/commitlint.yaml deleted file mode 100644 index e44658d8..00000000 --- a/.github/workflows/commitlint.yaml +++ /dev/null @@ -1,43 +0,0 @@ -name: "Lint commit messages" - -# Run on every push to main (or your default branch) and on PRs -on: - push: - branches: - - main - pull_request: - -jobs: - commit_lint: - runs-on: ubuntu-latest - - steps: - # 1. Fetch all history so we can diff commit ranges - - name: Checkout code - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - # 2. Set up Node.js (needed to run commitlint) - - name: Set up Node.js - uses: actions/setup-node@v3 - with: - node-version: "18" - - # 3. Install commitlint and the conventional-commits preset - - name: Install Commitlint - run: npm install @commitlint/cli @commitlint/config-conventional - - # 4. Run commitlint over the pushed or PR range - - name: Lint commits - run: | - if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then - FROM_SHA="${{ github.event.pull_request.base.sha }}" - TO_SHA="${{ github.event.pull_request.head.sha }}" - else - FROM_SHA="${{ github.event.before }}" - TO_SHA="${{ github.sha }}" - fi - - echo "Linting commits from $FROM_SHA to $TO_SHA" - npx commitlint --from "$FROM_SHA" --to "$TO_SHA" From 24fe518f7dc5260cedf2b5267b08d88e8061088e Mon Sep 17 00:00:00 2001 From: pqvr Date: Mon, 12 May 2025 06:55:20 -0400 Subject: [PATCH 4/5] chore: update to only check title against conventional commit --- .github/workflows/lint_pr_title.yaml | 29 ++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/lint_pr_title.yaml diff --git a/.github/workflows/lint_pr_title.yaml b/.github/workflows/lint_pr_title.yaml new file mode 100644 index 00000000..27dcc330 --- /dev/null +++ b/.github/workflows/lint_pr_title.yaml @@ -0,0 +1,29 @@ +name: "Lint PR title" + +on: + pull_request: + +jobs: + lint_pr_title: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: "18" + + - name: Install commitlint + run: npm install @commitlint/cli @commitlint/config-conventional + + - name: Lint PR title + run: | + # Grab the PR title + echo "${{ github.event.pull_request.title }}" > pr_title.txt + + # Run commitlint in `--edit` mode against that single-line file + npx commitlint --edit pr_title.txt --config commitlint.config.js From a4082c2b67d7e11d252b7bdeac6f7aca897381a3 Mon Sep 17 00:00:00 2001 From: pqvr Date: Mon, 12 May 2025 07:04:56 -0400 Subject: [PATCH 5/5] chore: update to use gh api to get title --- .github/workflows/lint_pr_title.yaml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/lint_pr_title.yaml b/.github/workflows/lint_pr_title.yaml index 27dcc330..05b4e7fe 100644 --- a/.github/workflows/lint_pr_title.yaml +++ b/.github/workflows/lint_pr_title.yaml @@ -2,6 +2,7 @@ name: "Lint PR title" on: pull_request: + types: [opened, edited, synchronize, reopened] jobs: lint_pr_title: @@ -20,10 +21,19 @@ jobs: - name: Install commitlint run: npm install @commitlint/cli @commitlint/config-conventional + - name: Get current PR title + id: get_title + uses: actions/github-script@v6 + with: + script: | + const pr = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.payload.pull_request.number, + }); + return pr.data.title; + - name: Lint PR title run: | - # Grab the PR title - echo "${{ github.event.pull_request.title }}" > pr_title.txt - - # Run commitlint in `--edit` mode against that single-line file + echo "${{ steps.get_title.outputs.result }}" > pr_title.txt npx commitlint --edit pr_title.txt --config commitlint.config.js