-
-
Notifications
You must be signed in to change notification settings - Fork 960
34 lines (29 loc) · 1.15 KB
/
commitlint.yml
File metadata and controls
34 lines (29 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
name: Commit Lint
on:
pull_request_target:
types: [opened, reopened, synchronize]
permissions:
contents: read
jobs:
commitlint:
if: github.event_name == 'pull_request_target'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Fetch PR head
run: git fetch origin pull/${{ github.event.pull_request.number }}/head:pr_head
- name: Run commitlint
run: |
merge_base_sha=$(git merge-base HEAD pr_head)
first_commit_sha=$(git rev-list --no-merges --reverse $merge_base_sha..pr_head | head -n 1)
if [ -z "$first_commit_sha" ]; then
echo "Could not determine the first commit of the PR. Skipping."
exit 0
fi
commit_message=$(git log -1 --pretty=%B $first_commit_sha)
# we can't use npx see https://github.com/conventional-changelog/commitlint/issues/613
echo '{}' > package.json
npm install --no-fund --no-audit @commitlint/config-conventional @commitlint/cli
echo "$commit_message" | ./node_modules/.bin/commitlint -g .commitlintrc