File tree Expand file tree Collapse file tree 1 file changed +20
-6
lines changed
Expand file tree Collapse file tree 1 file changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -2,14 +2,28 @@ name: Check Source Branch
22on :
33 pull_request :
44 branches :
5- - main
5+ - prod
6+ types :
7+ - opened
8+ - synchronize
9+ - reopened
10+ - edited
611jobs :
7- check-branch :
12+ check-source-branch :
13+ name : check-source-branch
814 runs-on : ubuntu-latest
915 steps :
10- - name : Verify source branch is 'develop'
16+ - name : Check source branch
1117 run : |
12- if [[ "${{ github.head_ref }}" != "develop" ]]; then
13- echo "Error: Pull request must come from the 'develop' branch"
18+ HEAD_BRANCH="${{ github.head_ref }}"
19+ BASE_BRANCH="${{ github.base_ref }}"
20+
21+ echo "PR: ${HEAD_BRANCH} → ${BASE_BRANCH}"
22+
23+ if [ "$BASE_BRANCH" = "prod" ] && [ "$HEAD_BRANCH" != "develop" ]; then
24+ echo "::error::Merging to 'prod' is only allowed from the 'develop' branch."
25+ echo "::error::Source branch '${HEAD_BRANCH}' is not permitted."
1426 exit 1
15- fi
27+ fi
28+
29+ echo "✅ Source branch '${HEAD_BRANCH}' is allowed to merge into '${BASE_BRANCH}'."
You can’t perform that action at this time.
0 commit comments