Skip to content

Commit 518e0d9

Browse files
committed
Reorganize steps to run individual checks only if the overall commit message checker failed
1 parent 3b8c821 commit 518e0d9

1 file changed

Lines changed: 14 additions & 15 deletions

File tree

.github/workflows/commit-checker.yaml

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,17 @@ jobs:
2626
name: Check Commit Message
2727
runs-on: ubuntu-latest
2828
steps:
29+
- name: Check overall commit Message
30+
uses: gsactions/commit-message-checker@v2
31+
with:
32+
excludeDescription: 'true' # optional: this excludes the description body of a pull request
33+
excludeTitle: 'true' # optional: this excludes the title of a pull request
34+
checkAllCommitMessages: 'true' # optional: this checks all commits associated with a pull request
35+
accessToken: ${{ secrets.GITHUB_TOKEN }} # github access token is only required if checkAllCommitMessages is true
36+
pattern: '^(?![A-Z].*\.)[A-Z].{0,49}(\r?|\r?\n(?:.{0,71}\r?\n)*(?:.{0,71}\.)?\r?\n?)$'
37+
error: "The commit messages do not follow "
2938
- name: Check Subject Line Length
39+
if: ${{ failure() }}
3040
uses: gsactions/commit-message-checker@v2
3141
with:
3242
excludeDescription: 'true' # optional: this excludes the description body of a pull request
@@ -36,7 +46,7 @@ jobs:
3646
pattern: '^.{0,50}(\n.*)*$'
3747
error: 'Subject line was too long, exceeding 50 characters. Continue in the body of the commit message'
3848
- name: Check Subject Line Capitalization
39-
if: ${{ success() || failure() }}
49+
if: ${{ failure() }}
4050
uses: gsactions/commit-message-checker@v2
4151
with:
4252
excludeDescription: 'true' # optional: this excludes the description body of a pull request
@@ -46,7 +56,7 @@ jobs:
4656
pattern: '^[A-Z]'
4757
error: 'Subject line must begin with an imperative verb in present tense and first letter in uppercase'
4858
- name: Check Subject Line Ending
49-
if: ${{ success() || failure() }}
59+
if: ${{ failure() }}
5060
uses: gsactions/commit-message-checker@v2
5161
with:
5262
excludeDescription: 'true' # optional: this excludes the description body of a pull request
@@ -56,7 +66,7 @@ jobs:
5666
pattern: '(?<![\.\?\!])$'
5767
error: 'Subject line must not end with a period, question mark or exclamation!'
5868
- name: Check Body Line Length
59-
if: ${{ success() || failure() }}
69+
if: ${{ failure() }}
6070
uses: gsactions/commit-message-checker@v2
6171
with:
6272
excludeDescription: 'true' # optional: this excludes the description body of a pull request
@@ -66,7 +76,7 @@ jobs:
6676
pattern: '^.+((\n*.{0,72}\n)*)*$'
6777
error: 'The body must not exceed 72 characters per line and must have end with a newline character.'
6878
- name: Check body ends with an appropriate punctuation (. or ? or !)
69-
if: ${{ success() || failure() }}
79+
if: ${{ failure() }}
7080
uses: gsactions/commit-message-checker@v2
7181
with:
7282
excludeDescription: 'true' # optional: this excludes the description body of a pull request
@@ -75,14 +85,3 @@ jobs:
7585
accessToken: ${{ secrets.GITHUB_TOKEN }} # github access token is only required if checkAllCommitMessages is true
7686
pattern: '^.+(\n*(.+[\.\!\?])*)*$'
7787
error: 'The text of the body must end with a period, question mark or exclamation!'
78-
# Check the full pattern, now that we covered more common mistakes.
79-
- name: Check overall commit Message
80-
if: ${{ success() }}
81-
uses: gsactions/commit-message-checker@v2
82-
with:
83-
excludeDescription: 'true' # optional: this excludes the description body of a pull request
84-
excludeTitle: 'true' # optional: this excludes the title of a pull request
85-
checkAllCommitMessages: 'true' # optional: this checks all commits associated with a pull request
86-
accessToken: ${{ secrets.GITHUB_TOKEN }} # github access token is only required if checkAllCommitMessages is true
87-
pattern: '^(?![A-Z].*\.)[A-Z].{0,49}(\r?|\r?\n(?:.{0,71}\r?\n)*(?:.{0,71}\.)?\r?\n?)$'
88-
error: "The commit messages do not follow "

0 commit comments

Comments
 (0)