Skip to content

Commit

Permalink
Add git commit message hook [patch]
Browse files Browse the repository at this point in the history
  • Loading branch information
gmyenni committed Mar 3, 2021
1 parent bd65e38 commit a3a3dd2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
9 changes: 9 additions & 0 deletions .githooks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Git Hooks

Hooks in this directory check your commit message, and enforce standards.

To use these hooks in your local workflow, run:

`git config core.hooksPath .githooks/hooks`

Read more about [customizing git hooks](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks)
11 changes: 11 additions & 0 deletions .githooks/hooks/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

# regex to validate in commit msg
commit_regex='(no version bump|patch|minor|major)'
error_msg="Aborting commit. Your commit message is missing versioning instructions.
Please add [no version bump], [patch], [minor], or [major] to your commit message"

if ! grep -iqE "$commit_regex" "$1"; then
echo "$error_msg" >&2
exit 1
fi
6 changes: 2 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ jobs:
id: tagging
run: |
value=`cat version.txt`
echo "::set-output name=release::$value"
value="v${value}"
echo "::set-output name=tag::$value"
- name: Tag new version for release
Expand All @@ -111,5 +109,5 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tagging.outputs.release }}
release_name: ${{ steps.tagging.outputs.release }}
tag_name: ${{ steps.tagging.outputs.tag }}
release_name: ${{ steps.tagging.outputs.tag }}

0 comments on commit a3a3dd2

Please sign in to comment.