diff --git a/.github/workflows/branch-name-check.yml b/.github/workflows/branch-name-check.yml new file mode 100644 index 0000000..604c752 --- /dev/null +++ b/.github/workflows/branch-name-check.yml @@ -0,0 +1,23 @@ +name: Branch Name Check + +on: + pull_request: + types: [opened, edited, synchronize, reopened] + +jobs: + check-branch-name: + runs-on: ubuntu-latest + steps: + - name: Check Branch Name + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const branchName = context.payload.pull_request.head.ref; + const regex = /^(bugfix|feature|test|refactor|chore|experimental)\/[\w-]+$/; + + if (!regex.test(branchName)) { + core.setFailed('Branch name does not match the required format: /. Allowed types: bugfix, feature, test, refactor, chore, experimental'); + } else { + console.log('Branch name matches the required format'); + }