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 name: Lint Commit Messages
on: [pull_request] on: [push, pull_request]
jobs: jobs:
commitlint: commitlint:
name: "Lint commit"
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout Project - name: Checkout Project
uses: actions/checkout@v2 uses: actions/checkout@v3
with: with:
# for pull_request so we can do HEAD^2 # for pull_request so we can do HEAD^2
fetch-depth: 2 fetch-depth: 2
@@ -15,18 +16,16 @@ jobs:
id: get_commit_message id: get_commit_message
run: | run: |
if [[ '${{ github.event_name }}' == 'push' ]]; then 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 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 fi
- name: "Check latest commit message" - name: "Check latest commit message"
run: | run: |
commit_regex='^Merge.+|(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert|types)(\(.+\))?: .{1,50}' PATTERN='^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 if ! [[ "${{ steps.get_commit_message.outputs.commit_message }}" =~ $PATTERN ]]; then
echo echo
echo " Error: proper commit message format is required for automated changelog generation." echo " Error: proper commit message format is required for automated changelog generation."
echo
echo " - See .github/COMMIT_CONVENTION.md for more details." echo " - See .github/COMMIT_CONVENTION.md for more details."
echo echo
exit 1 exit 1