ci: add validating step to workflow and git-hook to the code committing (#61)

* ci: add validate step to workflow and git-hook to commit

* ci: add validate step to workflow and git-hook to commit

---------

Co-authored-by: liuyu <>
This commit is contained in:
eball 2024-05-22 20:34:43 +08:00 committed by GitHub
parent 6b12243c5b
commit af39f0bb23
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 46 additions and 3 deletions

30
.githooks/commit-msg Normal file
View file

@ -0,0 +1,30 @@
#!/usr/bin/env bash
#
# @author : Mak Sophea
# @version : 1.0#
# Create a regex for a conventional commit.
commit_types="(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test|wip)"
convetional_commit_regex="^${commit_types}(\([a-z \-]+\))?!?: .+$"
# Get the commit message (the parameter we're given is just the path to the
# temporary file which holds the message).
commit_message=$(cat "$1")
# Check the message, if we match, all good baby.
if [[ "$commit_message" =~ $convetional_commit_regex ]]; then
echo -e "\e[32mCommit message meets Conventional Commit standards...\e[0m"
exit 0
fi
# Uh-oh, this is not a conventional commit, show an example and link to the spec.
echo -e "\e[31mThe commit message does not meet the Conventional Commit standard\e[0m"
echo "An example of a valid message is: "
echo " feat(login): add the 'remember me' button"
echo "More details at: https://www.conventionalcommits.org/en/v1.0.0/#summary"
echo "***********************************************************************"
echo "Here are the list of message type : ${commit_types}"
echo " <type>: <subject> max 50char ex :- fix: invalid request for login api"
echo " <type(<scope>):> <subject> (Max 50 char) - <scope> is option ex: - fix(user): email address is empty on profile api"
echo "***********************************************************************"
exit 1

View file

@ -0,0 +1,7 @@
#!/bin/sh
# This script will config git hook path into specific folder in your project. This script will invoked by maven build.
# @author : Mak Sophea
# @version : 1.0#
#
echo "config git hooksPath to .githooks folder for commit-msg and pre-push"
git config core.hooksPath .githooks

View file

@ -2,15 +2,21 @@ name: Lint and Test Charts
on:
push:
branches: [ "main" ]
branches: [ "main", "release-*" ]
pull_request:
branches: [ "main" ]
branches: [ "main", "release-*" ]
jobs:
lint-test:
runs-on: ubuntu-latest
steps:
- name: PR Conventional Commit Validation
uses: ytanikin/PRConventionalCommits@1.1.0
with:
task_types: '["feat","fix","docs","test","ci","refactor","perf","chore","revert"]'
add_label: 'true'
- name: Checkout
uses: actions/checkout@v3
with:

View file

@ -21,7 +21,7 @@ jobs:
run: |
v=1.5.0-$(date +"%Y%m%d")
echo "tag_version=$v" >> $GITHUB_OUTPUT
echo "latest_version=1.4.1"
echo "latest_version=1.4.2"
- name: Package installer
run: |