-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
61 lines (52 loc) · 1.9 KB
/
action.yml
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
name: 'commitlint-cli-action'
author: 'Dafnik'
description: 'A simple GitHub action to run @commitlint/cli checks.'
branding:
icon: 'git-commit'
color: 'purple'
inputs:
commitlint_version:
description: 'The version of commitlint to install'
required: false
default: 'latest'
runs:
using: 'composite'
steps:
- name: Cache commitlint
id: cache-commitlint
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-commitlint-cache@${{ inputs.commitlint_version }}
- name: Installing commitlint
shell: bash
run: npm install --global commitlint@${{ inputs.commitlint_version }} @commitlint/config-conventional
- name: Check if commitlint.config.js exists
shell: bash
id: check-file
run: |
if [ -f commitlint.config.js ]; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Installing @commitlint/config-conventional
shell: bash
if: steps.check-file.outputs.exists == 'false'
run: npm install --global @commitlint/config-conventional
- name: Creating commitlint.config.js
shell: bash
if: steps.check-file.outputs.exists == 'false'
run: |
echo "module.exports = { extends: ['@commitlint/config-conventional'] };" > commitlint.config.js
- name: Verify commitlint.config.js content
shell: bash
run: cat commitlint.config.js
- name: Validate current commit (last commit) with commitlint
shell: bash
if: github.event_name == 'push'
run: commitlint --from HEAD~1 --to HEAD --verbose
- name: Validate PR commits with commitlint
shell: bash
if: github.event_name == 'pull_request'
run: commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose