Skip to content

Commit 3a390f4

Browse files
feat(action): install, configure, and run commitlint
1 parent 9d089a6 commit 3a390f4

File tree

1 file changed

+35
-5
lines changed

1 file changed

+35
-5
lines changed

action.yml

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,46 @@
11
name: commitlint
22
description: Lint commit messages with GitHub Actions.
33
author: remarkablemark
4+
45
inputs:
5-
version:
6-
description: Description
7-
default: 1.2.3
6+
from:
7+
description: Lower end of the commit range to lint
8+
default: HEAD~1
9+
810
runs:
911
using: composite
1012
steps:
11-
- run: |
12-
echo 'version: ${{ inputs.version }}'
13+
- name: Install commitlint
1314
shell: bash
15+
run: |
16+
command -v commitlint || npm install --global commitlint
17+
commitlint --version
18+
19+
- name: Check config
20+
shell: bash
21+
run: |
22+
CONFIG=$(commitlint --print-config --no-color)
23+
24+
RULES_LENGTH=$(node << EOF
25+
const config = $CONFIG;
26+
console.log(Object.keys(config.rules).length);
27+
EOF)
28+
29+
if [[ $RULES_LENGTH == 0 ]]; then
30+
npm install --global @commitlint/config-conventional
31+
echo '{"extends":["@commitlint/config-conventional"]}' > .commitlintrc.json
32+
fi
33+
34+
- name: Run commitlint
35+
shell: bash
36+
run: commitlint --from=${{ inputs.from }}
37+
38+
- name: Cleanup
39+
shell: bash
40+
run: |
41+
npm uninstall --global commitlint @commitlint/config-conventional
42+
git reset --hard && git clean -d --force
43+
1444
branding:
1545
icon: terminal
1646
color: gray-dark

0 commit comments

Comments
 (0)