aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/commit-validation.yml
blob: be88a36922dad953b47f7d52bcc9c608ef5747f8 (plain)
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
name: commit-validation
on: [ push, pull_request ]

permissions:
  contents: read

jobs:
  check-commit-msg-length:
    runs-on: ubuntu-latest
    id: check-commit-msg-length
    steps:
    - uses: actions/checkout@v3
    - name: Check commit message length
      with:
        result-encoding: json
        script: |
          var longlines = [];
          const commits = ${{ toJSON(github.event.commits) }}
          for (const commit of commits) {
            if (/^.{79}/.test(commit.message)) {
              longlines.push(commit.sha)
            }
          }
          return longlines
    - name: Get result
      run: |
        result="${{steps.check-commit-msg-length.outputs.result}}"
        if [[ $result = "" ]]; then
          echo "Ok"
          exit 0
        else
          echo "Commit messages for these commits contain lines > 78 characters:"
          echo $result
          exit 1
        fi