Skip to content

Initial public release of retina #4

Initial public release of retina

Initial public release of retina #4

name: commit-message
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
types:
- opened
- synchronize
- edited
- reopened
jobs:
commit-message:
runs-on: ubuntu-20.04
steps:
- name: verify_commit_message
run: |
if [[ "${{ github.event_name }}" == pull_request ]]; then
commit_msg_header="${{ github.event.pull_request.title }}"
else
# get first line of commit message
commit_msg_header=`echo "${{ github.event.head_commit.message }}" | head -n 1`
fi
commit_msg_type_regex='feat|fix|refactor|style|test|docs|build|tool|chore|deps'
commit_msg_scope_regex='.{1,20}'
commit_msg_subject_regex='.{1,150}'
commit_msg_regex="^(${commit_msg_type_regex})(\(${commit_msg_scope_regex}\))?: (${commit_msg_subject_regex})\$"
merge_msg_regex="^Merge branch '.+' into .+\$"
full_regex="(${commit_msg_regex})|(${merge_msg_regex})"
echo $commit_msg_header | grep -qP "$full_regex" || {
echo "ERROR: Invalid commit message header. Please fix format of your PR title or the commit pushed to main."
echo "Current value:"
echo "$commit_msg_header"
echo
echo "Examples of valid commits:"
echo 'example 1: "feat(cli): new feature"'
echo 'example 2: "fix(advanced-metrics): bug fix"'
echo 'example 3: "docs: update readme"'
echo
echo "Valid types are: $commit_msg_type_regex"
echo "For more details, see .github/workflows/commit-message.yaml"
exit 1
}