mirror of
https://github.com/Snigdha-OS/snigdhaos-arctic.git
synced 2025-09-20 19:45:01 +02:00
🤖 ci(change): set according to out commit script
This commit is contained in:
52
.github/workflows/commit.yml
vendored
52
.github/workflows/commit.yml
vendored
@@ -1,4 +1,4 @@
|
||||
name: Conventional Commit Checker
|
||||
name: Check Conventional Commit
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -9,44 +9,30 @@ on:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
conventional-commit-checker:
|
||||
check-commit-message:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Check conventional commit message
|
||||
- name: Check Conventional Commit
|
||||
run: |
|
||||
COMMIT_MSG=$(git log -1 --format=%s)
|
||||
EMOJI=$(echo "$COMMIT_MSG" | cut -d' ' -f1)
|
||||
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-)
|
||||
# Define the conventional commit types with emojis
|
||||
TYPES=("🎉 feat" "🐞 fix" "📚 docs" "💅 style" "🔨 refactor" "⚡️ perf" "🧪 test" "🛠️ build" "🤖 ci" "🧹 chore" "⏪️ revert")
|
||||
|
||||
# Check if the emoji is valid
|
||||
if [[ " ${TYPES[*]} " =~ " ${EMOJI} " ]]; then
|
||||
echo "Valid emoji: ${EMOJI}"
|
||||
else
|
||||
echo "Error: Invalid emoji. Please use one of the following: 🎉, 🐞, 📚, 💅, 🔨, ⚡️, 🧪, 🛠️, 🤖, 🧹, ⏪️"
|
||||
exit 1
|
||||
# Extract the commit type and emoji from the commit message
|
||||
COMMIT_MSG=$(git log --format=%B -n 1)
|
||||
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
|
||||
|
||||
# Check if the type is valid
|
||||
if [[ " ${TYPES[*]} " =~ " ${TYPE} " ]]; then
|
||||
echo "Valid type: ${TYPE}"
|
||||
else
|
||||
echo "Error: Invalid type. Please use one of the following: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert"
|
||||
# If we reach here, the commit message is not a conventional commit
|
||||
echo "Commit message is not a conventional commit"
|
||||
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
|
Reference in New Issue
Block a user