fix: adjust Actions compatibility issues

This commit is contained in:
Igor
2023-03-16 19:07:08 +01:00
parent 227a3c7c6b
commit 6703e27e80

View File

@@ -1,12 +1,13 @@
name: Lint Commit Messages
on: [pull_request]
on: [push, pull_request]
jobs:
commitlint:
name: "Lint commit"
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
# for pull_request so we can do HEAD^2
fetch-depth: 2
@@ -15,18 +16,16 @@ jobs:
id: get_commit_message
run: |
if [[ '${{ github.event_name }}' == 'push' ]]; then
echo ::set-output name=commit_message::$(git log --format=%B -n 1 HEAD)
echo "commit_message=$(git log --format=%B -n 1 HEAD)" >> $GITHUB_OUTPUT
elif [[ '${{ github.event_name }}' == 'pull_request' ]]; then
echo ::set-output name=commit_message::$(git log --format=%B -n 1 HEAD^2)
echo "commit_message=$(git log --format=%B -n 1 HEAD^2)" >> $GITHUB_OUTPUT
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
PATTERN='^Merge.+|(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert|types)(\(.+\))?: .{1,50}'
if ! [[ "${{ steps.get_commit_message.outputs.commit_message }}" =~ $PATTERN ]]; 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