🤖 ci(change): set according to out commit script

This commit is contained in:
Eshan Roy (Eshanized)
2024-06-18 03:46:21 +05:30
parent dc3f938620
commit 35349e5d26

View File

@@ -1,4 +1,4 @@
name: Conventional Commit Checker name: Check Conventional Commit
on: on:
push: push:
@@ -9,44 +9,30 @@ on:
- master - master
jobs: jobs:
conventional-commit-checker: check-commit-message:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v2
- name: Check conventional commit message - name: Check Conventional Commit
run: | run: |
COMMIT_MSG=$(git log -1 --format=%s) # Define the conventional commit types with emojis
EMOJI=$(echo "$COMMIT_MSG" | cut -d' ' -f1) TYPES=("🎉 feat" "🐞 fix" "📚 docs" "💅 style" "🔨 refactor" "⚡️ perf" "🧪 test" "🛠️ build" "🤖 ci" "🧹 chore" "⏪️ revert")
TYPE=$(echo "$COMMIT_MSG" | cut -d'(' -f1 | cut -d' ' -f2-)
SCOPE=$(echo "$COMMIT_MSG" | cut -d'(' -f2 | cut -d')' -f1)
DESC=$(echo "$COMMIT_MSG" | cut -d']:' -f2-)
# Check if the emoji is valid # Extract the commit type and emoji from the commit message
if [[ " ${TYPES[*]} " =~ " ${EMOJI} " ]]; then COMMIT_MSG=$(git log --format=%B -n 1)
echo "Valid emoji: ${EMOJI}" for type in "${TYPES[@]}"; do
else type_emoji=${type}
echo "Error: Invalid emoji. Please use one of the following: 🎉, 🐞, 📚, 💅, 🔨, ⚡️, 🧪, 🛠️, 🤖, 🧹, ⏪️" type=${type_emoji#* }
exit 1 emoji=${type_emoji% *}
if [[ $COMMIT_MSG == $emoji* ]]; then
echo "Commit message is a conventional commit"
exit 0
fi fi
done
# Check if the type is valid # If we reach here, the commit message is not a conventional commit
if [[ " ${TYPES[*]} " =~ " ${TYPE} " ]]; then echo "Commit message is not a conventional commit"
echo "Valid type: ${TYPE}" exit 1
else
echo "Error: Invalid type. Please use one of the following: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert"
exit 1
fi
# Check if the scope is provided
if [ -z "$SCOPE" ]; then
echo "Error: Commit scope is required"
exit 1
fi
# Check if the description is provided
if [ -z "$DESC" ]; then
echo "Error: Commit description is required"
exit 1
fi