diff --git a/.github/workflows/BRANCH_NAME_CHECK_ON_PR.yml b/.github/workflows/BRANCH_NAME_CHECK_ON_PR.yml new file mode 100644 index 0000000000..a9d2e8a138 --- /dev/null +++ b/.github/workflows/BRANCH_NAME_CHECK_ON_PR.yml @@ -0,0 +1,22 @@ +on: + pull_request: + branches: + - main + - master + +jobs: + check-branch-name: + runs-on: ubuntu-latest + steps: + - name: Extract branch name + id: extract_branch + run: echo "::set-output name=branch::${GITHUB_HEAD_REF}" + - name: Check if branch name follows conventional commit regex + run: | + BRANCH_REGEX='^(feat|fix|docs|style|refactor|perf|test|chore)\(?.+\)?: .+$' + if [[ "${{ steps.extract_branch.outputs.branch }}" =~ $BRANCH_REGEX ]]; then + echo "Branch name follows the conventional commit format." + else + echo "Branch name does not follow the conventional commit format." + exit 1 + fi \ No newline at end of file