Skip to content

Commit 23c3cfc

Browse files
authored
fix: error on first commit (#25)
1 parent fc0b524 commit 23c3cfc

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

.github/workflows/commitlint.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@ jobs:
1717
node --version
1818
npm --version
1919
npx commitlint --version
20+
- name: Get commit count
21+
id: commit_count
22+
run: echo "commit_count=$(git rev-list HEAD --count)" >>$GITHUB_OUTPUT
2023
- name: Validate current commit (last commit) with commitlint
21-
if: github.event_name == 'push'
24+
if: github.event_name == 'push' && steps.commit_count.outputs.commit_count > 1
2225
run: npx commitlint --from HEAD~1 --to HEAD --verbose
2326
- name: Validate PR commits with commitlint
2427
if: github.event_name == 'pull_request'
25-
run: npx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose
28+
run: npx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose

0 commit comments

Comments
 (0)