28 lines
972 B
YAML
28 lines
972 B
YAML
name: "Check conventional commit message"
|
|
description: "Checks if a value follows the conventional commit message specification."
|
|
inputs:
|
|
value:
|
|
description: "The value to test."
|
|
required: true
|
|
|
|
runs:
|
|
using: "composite"
|
|
steps:
|
|
- name: Check conventional commit message
|
|
shell: bash
|
|
env:
|
|
INPUT_VALUE: ${{ inputs.value }}
|
|
run: |
|
|
set -eo pipefail
|
|
|
|
CONVENTIONAL_COMMIT_REGEX='^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\([[:alnum:]._-]+\))?(!)?: .+'
|
|
|
|
printf 'Checking "%s"...\n' "$INPUT_VALUE"
|
|
|
|
if ! printf '%s\n' "$INPUT_VALUE" | grep -qE "$CONVENTIONAL_COMMIT_REGEX"; then
|
|
echo "::error title=Invalid Commit Message::Input '$INPUT_VALUE' is not a valid conventional commit message."
|
|
echo "Please refer to the specification: https://www.conventionalcommits.org/en/v1.0.0/"
|
|
exit 1
|
|
else
|
|
echo "::notice::Input is valid :)"
|
|
fi
|