🤖 ci: conventional pipeline
This commit is contained in:
34
.gitlab-ci.yml
Normal file
34
.gitlab-ci.yml
Normal file
@@ -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
|
Reference in New Issue
Block a user