Skip to content

fix(docs): update doc, codespaces config and GHA on commit GPG signed #9

fix(docs): update doc, codespaces config and GHA on commit GPG signed

fix(docs): update doc, codespaces config and GHA on commit GPG signed #9

name: commit-verifier
on:
merge_group:
pull_request:
branches: [main]
types:
- opened
- synchronize
- edited
- reopened
jobs:
commit-verifier:
if: ${{ github.event_name != 'merge_group' }}
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: verify_commit_message
env:
TITLE: ${{ github.event.pull_request.title }}
run: |
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})"
grep -qP "$full_regex" <<< "$TITLE" || {
echo "ERROR: Invalid commit message header. Please fix format of your PR title."
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
}
- name: Verify GPG Signature
run: |
LAST_COMMIT=$(git rev-parse HEAD)
SIGNATURE=$(git log --show-signature -1 $LAST_COMMIT)
echo "$SIGNATURE" | grep 'gpg: Signature made' || {
echo "ERROR: The last commit is not GPG signed. Please sign your commit."
exit 1
}