Skip to content

Commit

Permalink
Reorganize steps to run individual checks only if the overall commit …
Browse files Browse the repository at this point in the history
…message checker failed
  • Loading branch information
arunkannawadi committed Jun 21, 2023
1 parent 3b8c821 commit 518e0d9
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions .github/workflows/commit-checker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,17 @@ jobs:
name: Check Commit Message
runs-on: ubuntu-latest
steps:
- name: Check overall commit Message
uses: gsactions/commit-message-checker@v2
with:
excludeDescription: 'true' # optional: this excludes the description body of a pull request
excludeTitle: 'true' # optional: this excludes the title of a pull request
checkAllCommitMessages: 'true' # optional: this checks all commits associated with a pull request
accessToken: ${{ secrets.GITHUB_TOKEN }} # github access token is only required if checkAllCommitMessages is true
pattern: '^(?![A-Z].*\.)[A-Z].{0,49}(\r?|\r?\n(?:.{0,71}\r?\n)*(?:.{0,71}\.)?\r?\n?)$'
error: "The commit messages do not follow "
- name: Check Subject Line Length
if: ${{ failure() }}
uses: gsactions/commit-message-checker@v2
with:
excludeDescription: 'true' # optional: this excludes the description body of a pull request
Expand All @@ -36,7 +46,7 @@ jobs:
pattern: '^.{0,50}(\n.*)*$'
error: 'Subject line was too long, exceeding 50 characters. Continue in the body of the commit message'
- name: Check Subject Line Capitalization
if: ${{ success() || failure() }}
if: ${{ failure() }}
uses: gsactions/commit-message-checker@v2
with:
excludeDescription: 'true' # optional: this excludes the description body of a pull request
Expand All @@ -46,7 +56,7 @@ jobs:
pattern: '^[A-Z]'
error: 'Subject line must begin with an imperative verb in present tense and first letter in uppercase'
- name: Check Subject Line Ending
if: ${{ success() || failure() }}
if: ${{ failure() }}
uses: gsactions/commit-message-checker@v2
with:
excludeDescription: 'true' # optional: this excludes the description body of a pull request
Expand All @@ -56,7 +66,7 @@ jobs:
pattern: '(?<![\.\?\!])$'
error: 'Subject line must not end with a period, question mark or exclamation!'
- name: Check Body Line Length
if: ${{ success() || failure() }}
if: ${{ failure() }}
uses: gsactions/commit-message-checker@v2
with:
excludeDescription: 'true' # optional: this excludes the description body of a pull request
Expand All @@ -66,7 +76,7 @@ jobs:
pattern: '^.+((\n*.{0,72}\n)*)*$'
error: 'The body must not exceed 72 characters per line and must have end with a newline character.'
- name: Check body ends with an appropriate punctuation (. or ? or !)
if: ${{ success() || failure() }}
if: ${{ failure() }}
uses: gsactions/commit-message-checker@v2
with:
excludeDescription: 'true' # optional: this excludes the description body of a pull request
Expand All @@ -75,14 +85,3 @@ jobs:
accessToken: ${{ secrets.GITHUB_TOKEN }} # github access token is only required if checkAllCommitMessages is true
pattern: '^.+(\n*(.+[\.\!\?])*)*$'
error: 'The text of the body must end with a period, question mark or exclamation!'
# Check the full pattern, now that we covered more common mistakes.
- name: Check overall commit Message
if: ${{ success() }}
uses: gsactions/commit-message-checker@v2
with:
excludeDescription: 'true' # optional: this excludes the description body of a pull request
excludeTitle: 'true' # optional: this excludes the title of a pull request
checkAllCommitMessages: 'true' # optional: this checks all commits associated with a pull request
accessToken: ${{ secrets.GITHUB_TOKEN }} # github access token is only required if checkAllCommitMessages is true
pattern: '^(?![A-Z].*\.)[A-Z].{0,49}(\r?|\r?\n(?:.{0,71}\r?\n)*(?:.{0,71}\.)?\r?\n?)$'
error: "The commit messages do not follow "

0 comments on commit 518e0d9

Please sign in to comment.