Skip to content

Commit 11ac293

Browse files
committed
fix(action): Properly fetch git history
Use checkout inside the action to correctly fetch the git history Fetch base branch tip commit Set only necessary flags, all other flags can be controled thru ENV variables
1 parent c3771ca commit 11ac293

1 file changed

Lines changed: 17 additions & 25 deletions

File tree

action.yaml

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,21 @@
1-
name: 'commit lint'
1+
name: 'convcommitlint'
22
description: 'Check if commits follow the conventional commits standard'
3+
branding:
4+
icon: 'git-commit'
5+
color: 'gray-dark'
36
inputs:
7+
fetch-depth:
8+
description: 'git fetch depth when checking out the repository'
9+
required: false
10+
default: "0"
411
base-branch: # id of input
512
description: 'base branch to lint from'
613
required: false
714
default: "main"
8-
comment-only:
9-
description: 'Do not request changes on pull requests'
10-
required: false
11-
default: "false"
1215
create-review:
13-
description: 'Creates a pull request revie'
16+
description: 'Creates a pull request review'
1417
required: false
1518
default: "true"
16-
current:
17-
description: 'Lints only current commit'
18-
required: false
19-
default: "false"
20-
lint-all:
21-
description: 'Lints all commits in the history'
22-
required: false
23-
default: "false"
24-
path:
25-
description: 'Path to the repository'
26-
required: false
27-
default: "./"
2819
version:
2920
description: 'go conventional commit version to run'
3021
required: false
@@ -39,16 +30,17 @@ runs:
3930
- name: "install conventional commit lint"
4031
shell: bash
4132
run: go install github.com/coolapso/convcommitlint@${{ inputs.version }}
33+
- uses: actions/checkout@v4
34+
with:
35+
fetch-depth: ${{ inputs.fetch-depth }}
36+
ref: ${{ github.head_ref }}
37+
- name: 'get base branch last commit'
38+
run: git fetch origin ${{ inputs.base-branch }}:${{ inputs.base-branch }} --depth 1
39+
shell: bash
4240
- name: "Lint commits"
4341
shell: bash
4442
run: |
45-
export CONVCOMLINT_BASE_BRANCH=${{ inputs.base-branch }}
46-
export CONVCOMLINT_COMMENT_ONLY=${{ inputs.comment-only }}
47-
export CONVCOMLINT_CREATE_REVIEW=${{ inputs.create-review }}
48-
export CONVCOMLINT_CURRENT=${{ inputs.current }}
49-
export CONVCOMLINT_LINT_ALL=${{ inputs.lint-all }}
50-
export CONVCOMLINT_PATH=${{ inputs.path }}
51-
convcommitlint
43+
convcommitlint -b ${{ inputs.base-branch }} --create-review=${{ inputs.create-review }}
5244
5345
5446

0 commit comments

Comments
 (0)