From 724b4acc145a696a7ac56c70a8a93d1ab9ff8984 Mon Sep 17 00:00:00 2001 From: Junha Date: Fri, 7 Jul 2023 13:33:32 +0000 Subject: [PATCH] chore: regular and git actions yml --- .github/commit-regular.txt | 1 + .github/workflows/commit-msg-check.yml | 30 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 .github/commit-regular.txt create mode 100644 .github/workflows/commit-msg-check.yml diff --git a/.github/commit-regular.txt b/.github/commit-regular.txt new file mode 100644 index 00000000..eb8e6c1b --- /dev/null +++ b/.github/commit-regular.txt @@ -0,0 +1 @@ +(feat|fix|refactor|style|docs|test|chore):.{1,50}(\n.{1,72})?$ \ No newline at end of file diff --git a/.github/workflows/commit-msg-check.yml b/.github/workflows/commit-msg-check.yml new file mode 100644 index 00000000..0aa44bf8 --- /dev/null +++ b/.github/workflows/commit-msg-check.yml @@ -0,0 +1,30 @@ +name: Commit Message Check + +on: [push] + +jobs: + commit_message_check: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Read Commit Regular Expression + id: read_commit_regex + run: | + commit_msg_regex=$(cat ./.github/commit-regular.txt) + echo "Commit Regular Expression: $commit_msg_regex" + echo "::set-output name=commit_regex::$commit_msg_regex" + + - name: Validate Commit Message + run: | + commit_msg=$(git log --format=%B -n 1 ${{ github.sha }}) + echo "Commit Message: $commit_msg" + commit_regex="${{ steps.read_commit_regex.outputs.commit_regex }}" + if [[ ! "$commit_msg" =~ $commit_regex ]]; then + echo "Invalid commit message format." + exit 1 + else + echo "Commit message is valid." + fi \ No newline at end of file