Skip to content

Commit

Permalink
feat(workflow): Add reusable CommitLint workflow (#41)
Browse files Browse the repository at this point in the history
* feat: Add reusable CommitLint workflow

* fix

* try fix

* add sample config

* fix?

* add missing quotes

* fix lint
  • Loading branch information
mircea-pavel-anton authored Sep 15, 2024
1 parent 5af65bf commit 9c43683
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 4 deletions.
13 changes: 13 additions & 0 deletions .commitlintrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
# Inherit configuration of a package
include: package:commitlint_cli/commitlint.yaml

# Custom rules
rules:
type-case:
- 2
- always
- "lower-case"

# Whether commitlint uses the default ignore rules.
defaultIgnores: true
11 changes: 7 additions & 4 deletions .github/workflows/lint-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ name: Lint

on:
workflow_dispatch: {}

pull_request:
paths:
- "**.yaml"
pull_request: {}

jobs:
yamllint:
Expand All @@ -31,3 +28,9 @@ jobs:
secrets: inherit
with:
markdownlint-cli-version: "0.41.0"

commitlint:
uses: ./.github/workflows/reusable-commitlint.yaml
secrets: inherit
with:
commitlint-version: "v19.5.0"
51 changes: 51 additions & 0 deletions .github/workflows/reusable-commitlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Reusable - CommitLint

on:
workflow_call:
inputs:
node-version:
description: "Node version"
required: false
type: string
default: "latest"
commitlint-version:
description: "Commitlint version"
required: false
type: string
default: "latest"

jobs:
commitlint:
runs-on: ubuntu-latest
steps:
- name: Generate Token
uses: actions/create-github-app-token@3378cda945da322a8db4b193e19d46352ebe2de5 # v1.10.4
id: app-token
with:
app-id: "${{ secrets.BOT_APP_ID }}"
private-key: "${{ secrets.BOT_APP_PRIVATE_KEY }}"

- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
token: "${{ steps.app-token.outputs.token }}"

- name: Set up Node
uses: actions/setup-node@v4.0.3
with:
node-version: "${{ inputs.node-version }}"

- name: Install commitlint
run: |
npm install conventional-changelog-conventionalcommits
npm install -g @commitlint/cli@${{ inputs.commitlint-version }}
- name: Validate PR commits with commitlint
if: github.event_name == 'pull_request'
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
echo "$PR_TITLE" > file.txt
commitlint --verbose --color -e=file.txt

0 comments on commit 9c43683

Please sign in to comment.