Skip to content

Commit 67efbf6

Browse files
fix(commitlint): handle exit codes correctly in workflow
1 parent a0eedd8 commit 67efbf6

2 files changed

Lines changed: 10 additions & 11 deletions

File tree

.git-hooks/commit-msg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#!/bin/sh
2+
set -e
23

3-
npx --yes @commitlint/cli --edit "$1"
4+
npx --yes @commitlint/cli --edit "$1"

.github/workflows/commit-lint.yml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,11 @@ jobs:
1919

2020
- name: Validate commit messages
2121
run: |
22-
git log \
23-
--no-merges \
24-
--pretty=format:"%H" \
25-
"${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}" \
26-
| while IFS= read -r sha; do
27-
tmp=$(mktemp)
28-
git log -1 --pretty=format:"%B" "$sha" > "$tmp"
29-
npx --yes @commitlint/cli@20.4.3 --edit "$tmp" || exit 1
30-
rm "$tmp"
31-
done
22+
set -eo pipefail
23+
commits=$(git log --no-merges --pretty=format:"%H" "${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}")
24+
for sha in $commits; do
25+
tmp=$(mktemp)
26+
git log -1 --pretty=format:"%B" "$sha" > "$tmp"
27+
npx --yes @commitlint/cli@20.4.3 --edit "$tmp"
28+
rm "$tmp"
29+
done

0 commit comments

Comments
 (0)