Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(workflow): Add reusable CommitLint workflow #41

Merged
merged 7 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading