Files
snigdhaos-arctic/.github/workflows/commit.yml
Eshan Roy (Eshanized) dc3f938620 🔨 refactor(workflows): enhanced
2024-06-16 02:27:33 +05:30

52 lines
1.6 KiB
YAML

name: Conventional Commit Checker
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
conventional-commit-checker:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Check conventional commit message
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-)
# 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
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