From 2550fe6c28a5f8624fa39ebf8d09fe01d594de2c Mon Sep 17 00:00:00 2001 From: Krum Tyukenov Date: Thu, 15 May 2025 17:28:44 +0300 Subject: [PATCH 1/3] add "Enforce Branch Name Rules" workflow --- .../workflows/enforce-branch-name-rules.yml | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/enforce-branch-name-rules.yml diff --git a/.github/workflows/enforce-branch-name-rules.yml b/.github/workflows/enforce-branch-name-rules.yml new file mode 100644 index 0000000000..baefbfe990 --- /dev/null +++ b/.github/workflows/enforce-branch-name-rules.yml @@ -0,0 +1,20 @@ +name: Enforce Branch Name Rules + +on: + pull_request: + branches: + - main + +jobs: + enforce-branch-rules: + runs-on: ubuntu-latest + steps: + - name: Check branch name + run: | + echo "Source branch: ${{ github.head_ref }}" + if [[ "${{ github.head_ref }}" != feature/* && \ + "${{ github.head_ref }}" != bugfix/* && \ + "${{ github.head_ref }}" != ric/* ]]; then + echo "❌ Pull requests to 'main' are only allowed from 'feature/**', 'bugfix/**', 'release/**', or 'ric/**' branches." + exit 1 + fi From 943ca70207b0d5738591f1a264ee3959e3d21601 Mon Sep 17 00:00:00 2001 From: Krum Tyukenov Date: Thu, 15 May 2025 17:35:39 +0300 Subject: [PATCH 2/3] whitelist release/* branch names --- .github/workflows/enforce-branch-name-rules.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/enforce-branch-name-rules.yml b/.github/workflows/enforce-branch-name-rules.yml index baefbfe990..b3ec6038c2 100644 --- a/.github/workflows/enforce-branch-name-rules.yml +++ b/.github/workflows/enforce-branch-name-rules.yml @@ -14,6 +14,7 @@ jobs: echo "Source branch: ${{ github.head_ref }}" if [[ "${{ github.head_ref }}" != feature/* && \ "${{ github.head_ref }}" != bugfix/* && \ + "${{ github.head_ref }}" != release/* && \ "${{ github.head_ref }}" != ric/* ]]; then echo "❌ Pull requests to 'main' are only allowed from 'feature/**', 'bugfix/**', 'release/**', or 'ric/**' branches." exit 1 From 9678225b188c722e3adac4a6d428ef85a7abe3cd Mon Sep 17 00:00:00 2001 From: Krum Tyukenov Date: Fri, 16 May 2025 12:39:58 +0300 Subject: [PATCH 3/3] whitelist dependabot/** branches --- .github/workflows/enforce-branch-name-rules.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/enforce-branch-name-rules.yml b/.github/workflows/enforce-branch-name-rules.yml index b3ec6038c2..94a9e97ad2 100644 --- a/.github/workflows/enforce-branch-name-rules.yml +++ b/.github/workflows/enforce-branch-name-rules.yml @@ -15,7 +15,8 @@ jobs: if [[ "${{ github.head_ref }}" != feature/* && \ "${{ github.head_ref }}" != bugfix/* && \ "${{ github.head_ref }}" != release/* && \ + "${{ github.head_ref }}" != dependabot/* && \ "${{ github.head_ref }}" != ric/* ]]; then - echo "❌ Pull requests to 'main' are only allowed from 'feature/**', 'bugfix/**', 'release/**', or 'ric/**' branches." + echo "❌ Pull requests to 'main' are only allowed from 'feature/**', 'bugfix/**', 'release/**', 'dependabot/**', or 'ric/**' branches." exit 1 fi