From 06a429c608c86425f4ff588e82d1be7eab591f0a Mon Sep 17 00:00:00 2001 From: eshanized Date: Sat, 18 Jan 2025 05:41:46 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20ci:=20conventional=20pipeline?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .gitlab-ci.yml 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