From 65a8a61d460fc5c6d53ec360d08e9759078d57d5 Mon Sep 17 00:00:00 2001 From: Eshan Roy Date: Sat, 13 Jul 2024 12:32:54 +0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20ci(workflows):=20replace=20and?= =?UTF-8?q?=20alter=20commit=20check?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/commit-check.yml | 38 +++++++++++++++++++ .../snigdhaos-commitizen-on-push.yml | 30 --------------- .../workflows/snigdhaos-commitzen-on-pull.yml | 30 --------------- 3 files changed, 38 insertions(+), 60 deletions(-) create mode 100644 .github/workflows/commit-check.yml delete mode 100644 .github/workflows/snigdhaos-commitizen-on-push.yml delete mode 100644 .github/workflows/snigdhaos-commitzen-on-pull.yml diff --git a/.github/workflows/commit-check.yml b/.github/workflows/commit-check.yml new file mode 100644 index 0000000..85980e7 --- /dev/null +++ b/.github/workflows/commit-check.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 diff --git a/.github/workflows/snigdhaos-commitizen-on-push.yml b/.github/workflows/snigdhaos-commitizen-on-push.yml deleted file mode 100644 index 5f3fa55..0000000 --- a/.github/workflows/snigdhaos-commitizen-on-push.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Snigdha OS Commitizen Check on Push - -on: - push: - branches: - - master - -jobs: - commitizen_check: - name: Check Commitizen Commit on Push - runs-on: ubuntu-latest - - steps: - - name: Checkout Repository - uses: actions/checkout@v2 - - - name: Install Node.js - uses: actions/setup-node@v3 - with: - node-version: '14' - - - name: Install Commitizen - run: npm install -g commitizen - - - name: Verify Commitizen Commit - run: | - if git log --format='%s' ${{ github.event.before }}..${{ github.sha }} | grep -v '^(feat|fix|docs|style|refactor|perf|test|chore)(\(.+\))?: .+'; then - echo "Invalid commit message found. Please use Commitizen convention." - exit 1 - fi \ No newline at end of file diff --git a/.github/workflows/snigdhaos-commitzen-on-pull.yml b/.github/workflows/snigdhaos-commitzen-on-pull.yml deleted file mode 100644 index c80a671..0000000 --- a/.github/workflows/snigdhaos-commitzen-on-pull.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Snigdha OS Commitizen Check On Pull - -on: - pull_request: - branches: - - master - -jobs: - commitizen_check: - name: Check Commitizen Commit on Pull Request - runs-on: ubuntu-latest - - steps: - - name: Checkout Repository - uses: actions/checkout@v2 - - - name: Install Node.js - uses: actions/setup-node@v3 - with: - node-version: '14' - - - name: Install Commitizen - run: npm install -g commitizen - - - name: Verify Commitizen Commit - run: | - if git log --format='%s' ${{ github.event.before }}..${{ github.sha }} | grep -v '^(feat|fix|docs|style|refactor|perf|test|chore)(\(.+\))?: .+'; then - echo "Invalid commit message found. Please use Commitizen convention." - exit 1 - fi \ No newline at end of file