From e797bbdcb975b91394201b87dd045151023ea51e Mon Sep 17 00:00:00 2001 From: orama254 Date: Fri, 13 Mar 2026 17:31:26 +0300 Subject: [PATCH] chore(ci-cd): refactor the branch enforcement workflow --- .github/workflows/branch-check.yml | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/.github/workflows/branch-check.yml b/.github/workflows/branch-check.yml index ff6c7c2..03ec56c 100644 --- a/.github/workflows/branch-check.yml +++ b/.github/workflows/branch-check.yml @@ -2,14 +2,28 @@ name: Check Source Branch on: pull_request: branches: - - main + - prod + types: + - opened + - synchronize + - reopened + - edited jobs: - check-branch: + check-source-branch: + name: check-source-branch runs-on: ubuntu-latest steps: - - name: Verify source branch is 'develop' + - name: Check source branch run: | - if [[ "${{ github.head_ref }}" != "develop" ]]; then - echo "Error: Pull request must come from the 'develop' branch" + HEAD_BRANCH="${{ github.head_ref }}" + BASE_BRANCH="${{ github.base_ref }}" + + echo "PR: ${HEAD_BRANCH} → ${BASE_BRANCH}" + + if [ "$BASE_BRANCH" = "prod" ] && [ "$HEAD_BRANCH" != "develop" ]; then + echo "::error::Merging to 'prod' is only allowed from the 'develop' branch." + echo "::error::Source branch '${HEAD_BRANCH}' is not permitted." exit 1 - fi \ No newline at end of file + fi + + echo "✅ Source branch '${HEAD_BRANCH}' is allowed to merge into '${BASE_BRANCH}'." \ No newline at end of file