From c4fc5110f3f50592d047a869c6cc89472f2366c0 Mon Sep 17 00:00:00 2001 From: fatmahgazy <143911324+fatmahgazy@users.noreply.github.com> Date: Thu, 15 May 2025 00:50:01 +0200 Subject: [PATCH 1/2] add branch name check rule --- .github/workflows/branch-name-check.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/branch-name-check.yml diff --git a/.github/workflows/branch-name-check.yml b/.github/workflows/branch-name-check.yml new file mode 100644 index 0000000..5208390 --- /dev/null +++ b/.github/workflows/branch-name-check.yml @@ -0,0 +1,24 @@ +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: JIRA--(bugfix|experimental|feature|test|refactor|chore)/'); + } else { + console.log('Branch name matches the required format'); + } + From a0e2085d95716cd9ab930a6c7dbd8507e451b2f5 Mon Sep 17 00:00:00 2001 From: fatmahgazy <143911324+fatmahgazy@users.noreply.github.com> Date: Thu, 15 May 2025 00:58:56 +0200 Subject: [PATCH 2/2] update branch name check file --- .github/workflows/branch-name-check.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/branch-name-check.yml b/.github/workflows/branch-name-check.yml index 5208390..604c752 100644 --- a/.github/workflows/branch-name-check.yml +++ b/.github/workflows/branch-name-check.yml @@ -11,14 +11,13 @@ jobs: - name: Check Branch Name uses: actions/github-script@v6 with: - github-token: ${{secrets.GITHUB_TOKEN}} + github-token: ${{ secrets.GITHUB_TOKEN }} script: | const branchName = context.payload.pull_request.head.ref; - const regex = /^(bugfix|feature|test|refactor|chore| experimental)\/[\w-]+$/; + const regex = /^(bugfix|feature|test|refactor|chore|experimental)\/[\w-]+$/; if (!regex.test(branchName)) { - core.setFailed('Branch name does not match the required format: JIRA--(bugfix|experimental|feature|test|refactor|chore)/'); + 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'); } -