34 lines
1.4 KiB
YAML
34 lines
1.4 KiB
YAML
name: Lint Commit Messages
|
|
on: [pull_request]
|
|
|
|
jobs:
|
|
commitlint:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout Project
|
|
uses: actions/checkout@v2
|
|
with:
|
|
# for pull_request so we can do HEAD^2
|
|
fetch-depth: 2
|
|
|
|
- name: Get commit message
|
|
id: get_commit_message
|
|
run: |
|
|
if [[ '${{ github.event_name }}' == 'push' ]]; then
|
|
echo ::set-output name=commit_message::$(git log --format=%B -n 1 HEAD)
|
|
elif [[ '${{ github.event_name }}' == 'pull_request' ]]; then
|
|
echo ::set-output name=commit_message::$(git log --format=%B -n 1 HEAD^2)
|
|
fi
|
|
|
|
- name: "Check latest commit message"
|
|
run: |
|
|
commit_regex='^Merge.+|(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert|types)(\(.+\))?: .{1,50}'
|
|
if ! grep -iqE "$commit_regex" "${{ steps.get_commit_message.outputs.commit_message }}"; then
|
|
echo
|
|
echo " Error: proper commit message format is required for automated changelog generation."
|
|
echo
|
|
echo " - See .github/COMMIT_CONVENTION.md for more details."
|
|
echo
|
|
exit 1
|
|
fi
|