Skip to content

Commit d814b53

Browse files
committed
fix(ci): lint only first-parent commits to skip upstream merge history
1 parent c8e459a commit d814b53

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

.github/workflows/commitlint.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,17 @@ jobs:
2323
- name: Lint commit message
2424
run: |
2525
if [ "${{ github.event_name }}" = "pull_request" ]; then
26-
yarn commitlint --from=${{ github.event.pull_request.base.sha }} --to=${{ github.event.pull_request.head.sha }}
26+
# Only lint first-parent non-merge commits to skip merged upstream history
27+
commits=$(git rev-list --no-merges --first-parent \
28+
${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }})
29+
if [ -n "$commits" ]; then
30+
for sha in $commits; do
31+
echo "Linting commit $sha..."
32+
yarn commitlint --from="$sha~1" --to="$sha"
33+
done
34+
else
35+
echo "No non-merge commits to lint"
36+
fi
2737
else
2838
yarn commitlint --from=HEAD~1
2939
fi

0 commit comments

Comments
 (0)