From 5be074f117c65c0563d1ddf208428f6c1a41b38c Mon Sep 17 00:00:00 2001 From: Jack Sullivan Date: Sun, 10 Aug 2025 12:32:30 -0700 Subject: [PATCH 1/5] feat: conventional commit script and workflow --- .github/workflows/conventional-commit.yml | 18 ++++++++++++++ scripts/conventional-commit.sh | 29 +++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 .github/workflows/conventional-commit.yml create mode 100755 scripts/conventional-commit.sh diff --git a/.github/workflows/conventional-commit.yml b/.github/workflows/conventional-commit.yml new file mode 100644 index 0000000..9445271 --- /dev/null +++ b/.github/workflows/conventional-commit.yml @@ -0,0 +1,18 @@ +name: Conventional Commit Check +on: + pull_request: + types: + - opened + - edited + - synchronize + - reopened + +jobs: + check-title: + name: Conventional Commit + runs-on: ubuntu-latest + permissions: + pull-requests: read + steps: + - name: Validate PR title + run: ./scripts/conventional-commit.sh ${{ github.event.pull_request.title }} diff --git a/scripts/conventional-commit.sh b/scripts/conventional-commit.sh new file mode 100755 index 0000000..cca1a3e --- /dev/null +++ b/scripts/conventional-commit.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +set -euo pipefail + +TITLE="${1:-}" +if [[ -z "$TITLE" ]]; then + echo "::error::PR title is required" + exit 1 +fi + +TYPES_REGEX="build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test" + +# Conventional Commits: ()?(!)?: +RE="^(${TYPES_REGEX})(\([A-Za-z0-9._/-]+\))?(!)?: .+" + +if [[ ! "$TITLE" =~ $RE ]]; then + echo "::error::PR title must follow Conventional Commits. +Received: \"$TITLE\" +Expected: ()?: +Allowed types: ${TYPES_REGEX//|/, } +Examples: + - feat(api): add token exchange + - fix(auth)!: reject blank client_id + - chore: bump dependencies +" + exit 1 +fi + +echo "PR title OK: $TITLE" From 61376e4665fa8c89bde347735968b25a1930b9eb Mon Sep 17 00:00:00 2001 From: Jack Sullivan Date: Sun, 10 Aug 2025 12:36:44 -0700 Subject: [PATCH 2/5] Checkout code in conventional commit workflow --- .github/workflows/conventional-commit.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/conventional-commit.yml b/.github/workflows/conventional-commit.yml index 9445271..2895834 100644 --- a/.github/workflows/conventional-commit.yml +++ b/.github/workflows/conventional-commit.yml @@ -14,5 +14,8 @@ jobs: permissions: pull-requests: read steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Validate PR title run: ./scripts/conventional-commit.sh ${{ github.event.pull_request.title }} From 45c480031dd4ba2c6c37d12f4ac4d557a303c706 Mon Sep 17 00:00:00 2001 From: Jack Sullivan Date: Sun, 10 Aug 2025 12:42:41 -0700 Subject: [PATCH 3/5] Rename PR format workflow --- ...conventional-commit.yml => pull-request-format.yml} | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) rename .github/workflows/{conventional-commit.yml => pull-request-format.yml} (71%) diff --git a/.github/workflows/conventional-commit.yml b/.github/workflows/pull-request-format.yml similarity index 71% rename from .github/workflows/conventional-commit.yml rename to .github/workflows/pull-request-format.yml index 2895834..7cd536f 100644 --- a/.github/workflows/conventional-commit.yml +++ b/.github/workflows/pull-request-format.yml @@ -1,4 +1,4 @@ -name: Conventional Commit Check +name: PR Format Checks on: pull_request: types: @@ -8,11 +8,11 @@ on: - reopened jobs: - check-title: - name: Conventional Commit + conventional-commit: + name: Conventional Commit Title runs-on: ubuntu-latest - permissions: - pull-requests: read + # permissions: + # pull-requests: read steps: - name: Checkout code uses: actions/checkout@v4 From 6f66ed97d4a30229c8d8740f3f94e690c9a2a9b2 Mon Sep 17 00:00:00 2001 From: Jack Sullivan Date: Sun, 10 Aug 2025 12:45:02 -0700 Subject: [PATCH 4/5] Quote the PR title value --- .github/workflows/pull-request-format.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request-format.yml b/.github/workflows/pull-request-format.yml index 7cd536f..37c24e0 100644 --- a/.github/workflows/pull-request-format.yml +++ b/.github/workflows/pull-request-format.yml @@ -18,4 +18,4 @@ jobs: uses: actions/checkout@v4 - name: Validate PR title - run: ./scripts/conventional-commit.sh ${{ github.event.pull_request.title }} + run: ./scripts/conventional-commit.sh "${{ github.event.pull_request.title }}" From 543d692c79c726d0ccd20668338f03901a43e0fc Mon Sep 17 00:00:00 2001 From: Jack Sullivan Date: Sun, 10 Aug 2025 12:46:54 -0700 Subject: [PATCH 5/5] Rename PR Code Checks workflow --- .github/workflows/{pull-request.yml => pull-request-code.yml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{pull-request.yml => pull-request-code.yml} (99%) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request-code.yml similarity index 99% rename from .github/workflows/pull-request.yml rename to .github/workflows/pull-request-code.yml index c05c622..de1b0e9 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request-code.yml @@ -1,4 +1,4 @@ -name: Pull Request Checks +name: PR Code Checks on: pull_request: