diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..a524b9a --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,34 @@ +stages: + - validate + +check_conventional_commit: + stage: validate + image: ubuntu:latest + script: + - apt-get update && apt-get install -y git + - | + # Define the conventional commit types with emojis + TYPES=("๐Ÿš€ feat" "๐Ÿ› fix" "๐Ÿ“ docs" "โœจ style" "๐Ÿ›  refactor" "โšก๏ธ perf" "๐Ÿ”ฌ test" "๐Ÿ”ง build" "๐Ÿค– ci" "๐Ÿงน chore" "โช revert") + + # Extract the commit message from the latest commit + COMMIT_MSG=$(git log --format=%B -n 1) + echo "Latest Commit Message: $COMMIT_MSG" + + # Check if the commit message matches any of the conventional commit patterns + for type in "${TYPES[@]}"; do + type_emoji=${type} + type=${type_emoji#* } + emoji=${type_emoji% *} + if [[ $COMMIT_MSG == $emoji* ]]; then + echo "โœ… Commit message is a conventional commit" + exit 0 + fi + done + + # If no match is found, fail the pipeline + echo "โŒ Commit message is not a conventional commit" + exit 1 + only: + - master + - merge_requests + - pushes