From 84bfc35844f360eeb18c925733d05616c53e2441 Mon Sep 17 00:00:00 2001 From: "Eshan Roy (Eshanized)" <148610067+eshanized@users.noreply.github.com> Date: Sun, 16 Jun 2024 01:44:25 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20chore(workflows):=20conventional?= =?UTF-8?q?=20commit=20check?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/commit.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/commit.yml diff --git a/.github/workflows/commit.yml b/.github/workflows/commit.yml new file mode 100644 index 0000000..2621fff --- /dev/null +++ b/.github/workflows/commit.yml @@ -0,0 +1,35 @@ +name: Conventional Commit Checker + +on: + push: + branches: + - main + - master + - development + +jobs: + conventional-commit-checker: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - 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 + run: | + conventional_types=("build" "chore" "ci" "docs" "feat" "fix" "perf" "refactor" "revert" "style" "test") + commit_emojis=("build"="๐Ÿ—๏ธ" "chore"="๐Ÿงน" "ci"="๐Ÿค–" "docs"="๐Ÿ“š" "feat"="๐ŸŽ‰" "fix"="๐Ÿ”ง" "perf"="โšก๏ธ" "refactor"="๐Ÿ’ก" "revert"="๐Ÿšจ" "style"="๐Ÿ’„" "test"="๐Ÿงช") + + for type in "${conventional_types[@]}"; do + if [[ $LATEST_COMMIT_MESSAGE == *"${commit_emojis[$type]} $type:"* ]] || [[ $LATEST_COMMIT_MESSAGE == *"${commit_emojis[$type]} $type("* ]]; then + echo "Conventional commit message found: $LATEST_COMMIT_MESSAGE" + exit 0 + fi + done + + echo "Error: Commit message is not conventional" + exit 1 \ No newline at end of file