From 780dd5ca067195e3a8d2672fec7261f51c4c23d0 Mon Sep 17 00:00:00 2001 From: Eshan Roy Date: Tue, 19 Nov 2024 05:20:28 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=89=20feat(conv):=20conventional=20com?= =?UTF-8?q?mit=20checker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/commit.yml | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 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..5cda42d --- /dev/null +++ b/.github/workflows/commit.yml @@ -0,0 +1,38 @@ +name: Check Conventional Commit + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + check-commit-message: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Check Conventional Commit + run: | + # Define the conventional commit types with emojis + TYPES=("๐ŸŽ‰ feat" "๐Ÿž fix" "๐Ÿ“š docs" "๐Ÿ’… style" "๐Ÿ”จ refactor" "โšก๏ธ perf" "๐Ÿงช test" "๐Ÿ› ๏ธ build" "๐Ÿค– ci" "๐Ÿงน chore" "โช๏ธ revert") + + # 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 + + # If we reach here, the commit message is not a conventional commit + echo "Commit message is not a conventional commit" + exit 1 \ No newline at end of file