mirror of
https://github.com/jgm/pandoc.git
synced 2026-07-10 19:37:12 +00:00
56df2f1c17
The PR event doesn't include the actual commits, just a count and a URL to fetch it. But we can checkout the entire git history, we don't have so many commits that we need to optimize this just yet. And then we might as well use `git` itself to walk the commit history. (Using the remote commits URL would be useful only if we'd want to do a shallow clone because we have too many commits) Signed-off-by: Edwin Török <edwin@etorok.net>
40 lines
1.1 KiB
YAML
40 lines
1.1 KiB
YAML
name: commit-validation
|
|
on: [ push ]
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
check-commit-msg-length:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- 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
|