mirror of
https://github.com/Snigdha-OS/snigdhaos-arctic.git
synced 2025-09-20 19:45:01 +02:00
🔨 refactor(workflows): enhanced
This commit is contained in:
58
.github/workflows/commit.yml
vendored
58
.github/workflows/commit.yml
vendored
@@ -3,38 +3,50 @@ name: Conventional Commit Checker
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
|
||||||
- master
|
- master
|
||||||
- development
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
conventional-commit-checker:
|
conventional-commit-checker:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Get latest commit message
|
|
||||||
run: |
|
|
||||||
LATEST_COMMIT_MESSAGE=$(git log -1 --format=%s)
|
|
||||||
echo "LATEST_COMMIT_MESSAGE=$LATEST_COMMIT_MESSAGE" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Check conventional commit message
|
- name: Check conventional commit message
|
||||||
run: |
|
run: |
|
||||||
conventional_types=("build" "chore" "ci" "docs" "feat" "fix" "perf" "refactor" "revert" "style" "test")
|
COMMIT_MSG=$(git log -1 --format=%s)
|
||||||
commit_emojis=("build"="🏗️" "chore"="🧹" "ci"="🤖" "docs"="📚" "feat"="🎉" "fix"="🔧" "perf"="⚡️" "refactor"="💡" "revert"="🚨" "style"="💄" "test"="🧪")
|
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-)
|
||||||
|
|
||||||
echo "LATEST_COMMIT_MESSAGE: $LATEST_COMMIT_MESSAGE"
|
# Check if the emoji is valid
|
||||||
|
if [[ " ${TYPES[*]} " =~ " ${EMOJI} " ]]; then
|
||||||
for type in "${conventional_types[@]}"; do
|
echo "Valid emoji: ${EMOJI}"
|
||||||
pattern="${commit_emojis[$type]} ${type}(:|)?"
|
else
|
||||||
echo "Searching for pattern: $pattern"
|
echo "Error: Invalid emoji. Please use one of the following: 🎉, 🐞, 📚, 💅, 🔨, ⚡️, 🧪, 🛠️, 🤖, 🧹, ⏪️"
|
||||||
if echo "$LATEST_COMMIT_MESSAGE" | grep -qE "^$pattern"; then
|
|
||||||
echo "Conventional commit message found: $LATEST_COMMIT_MESSAGE"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "Error: Commit message is not conventional"
|
|
||||||
exit 1
|
exit 1
|
||||||
shell: bash
|
fi
|
||||||
|
|
||||||
|
# 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"
|
||||||
|
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