Skip to content

Commit ae51d6a

Browse files
committed
ci: improve commit lint
1 parent 078b1a6 commit ae51d6a

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

.github/workflows/commitlint.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,18 @@ jobs:
1212
- uses: actions/checkout@v4
1313
with:
1414
fetch-depth: 0
15+
- name: Fetch PR head
16+
run: git fetch origin pull/${{ github.event.pull_request.number }}/head:pr_head
1517
- name: Run commitlint
1618
run: |
17-
base_sha="${{ github.event.pull_request.base.sha }}"
18-
head_sha="${{ github.event.pull_request.head.sha }}"
19-
first_commit_sha=$(git rev-list --no-merges --reverse $base_sha..$head_sha | head -n 1)
19+
merge_base_sha=$(git merge-base HEAD pr_head)
20+
first_commit_sha=$(git rev-list --no-merges --reverse $merge_base_sha..pr_head | head -n 1)
21+
22+
if [ -z "$first_commit_sha" ]; then
23+
echo "Could not determine the first commit of the PR. Skipping."
24+
exit 0
25+
fi
26+
2027
commit_message=$(git log -1 --pretty=%B $first_commit_sha)
2128
# we can't use npx see https://github.com/conventional-changelog/commitlint/issues/613
2229
echo '{}' > package.json

0 commit comments

Comments
 (0)