-
Notifications
You must be signed in to change notification settings - Fork 1
80 lines (74 loc) · 2.66 KB
/
conventional-commit.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
---
'on':
workflow_call:
inputs:
jobs_run_on:
default: ubuntu-latest
description: The runner group on which jobs will run.
required: false
type: string
timeout_minutes:
description: The maximum time (in minutes) for a job to run.
default: 5
required: false
type: number
working_directory:
description: The working directory where all jobs should be executed.
default: '.'
required: false
type: string
validate_pr_title:
description: Validate PR title
default: true
required: false
type: boolean
validate_current_commit:
description: Validate current commit (last commit)
default: false
required: false
type: boolean
validate_pr_commits:
description: Validate PR commits
default: false
required: false
type: boolean
jobs:
conventional-commits:
defaults:
run:
working-directory: ${{ inputs.working_directory }}
runs-on: ${{ inputs.jobs_run_on }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Install commitlint
run: |
npm install --save-dev @commitlint/{cli,config-conventional}
# I hate myself for the below
cat <<- EOF > commitlint.config.ts
import type {UserConfig} from '@commitlint/types';
import {RuleConfigSeverity} from '@commitlint/types';
const Configuration: UserConfig = {
extends: ['@commitlint/config-conventional'],
rules: {
'subject-case': [0, 'never', []],
'body-max-line-length': [0, 'always', 100],
},
};
export default Configuration;
EOF
- name: Validate PR Title
if: github.event_name == 'pull_request' && inputs.validate_pr_title == true
run: echo "${{ github.event.pull_request.title }}" | npx commitlint --verbose
- name: Validate current commit (last commit) with commitlint
if: github.event_name == 'push' && inputs.validate_current_commit == true
run: npx commitlint --last --verbose
- name: Validate PR commits with commitlint
if: github.event_name == 'pull_request' && inputs.validate_pr_commits == true
# yamllint disable-line rule:line-length
run: npx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose
timeout-minutes: ${{ inputs.timeout_minutes }}