forked from jgm/pandoc
-
Notifications
You must be signed in to change notification settings - Fork 0
39 lines (37 loc) · 1.09 KB
/
commit-validation.yml
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
35
36
37
38
39
name: commit-validation
on: [ push ]
permissions:
contents: read
jobs:
check-commit-msg-length:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check commit message length
id: check-commit-msg-length
uses: actions/github-script@v7
with:
result-encoding: json
script: |
var longlines = 0;
const commits = ${{ toJSON(github.event.commits) }};
for (const commit of commits) {
for (const line of commit.message.split('\n')) {
if (line.length > 78) {
longlines += 1;
console.log("Overlong line:\n" + line);
}
}
}
return longlines
- name: Get result
run: |
result=${{steps.check-commit-msg-length.outputs.result}}
if [[ $result -eq 0 ]]; then
echo "Ok"
exit 0
else
echo "Commit messages contain $result lines longer than 78 characters."
echo "See under 'Check commit message length' for a list of the lines."
exit 1
fi