diff --git a/.github/workflows/commitlint-pr-title.yaml b/.github/workflows/commitlint-pr-title.yaml new file mode 100644 index 00000000..e3608897 --- /dev/null +++ b/.github/workflows/commitlint-pr-title.yaml @@ -0,0 +1,30 @@ +name: Lint PR Title + +on: + pull_request: + types: [opened, edited, synchronize] + +jobs: + pr-title-lint: + runs-on: ubuntu-latest + + steps: + - name: Check out Git repository + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: "22" + cache: npm + + - name: Install Commitlint + run: | + npm install @commitlint/{config-conventional,cli} + + - name: Lint PR Title + run: | + # Extract the PR title + pr_title=$(echo "${{ github.event.pull_request.title }}") + # Validate the PR title using commitlint + echo "$pr_title" | npx commitlint --config commitlint.config.mjs diff --git a/commitlint.config.mjs b/commitlint.config.mjs new file mode 100644 index 00000000..6de0ec45 --- /dev/null +++ b/commitlint.config.mjs @@ -0,0 +1,20 @@ +export default { + extends: ["@commitlint/config-conventional"], + rules: { + "scope-empty": [1, "never"], + "scope-enum": [ + 2, + "always", + [ + "repo", + "commitlint", + "pull-request", + "npm-publish", + "push-docker", + "push-helm", + "update-artifacts", + ], + ], + "header-min-length": [2, "always", 10], + }, +};