Create restrict-branch-merge.yml #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Enforce Branch Merge Rules" | |
on: | |
pull_request: | |
branches: | |
- main | |
- release | |
jobs: | |
check-branch: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Enforce develop -> release | |
if: github.ref == 'refs/heads/release' && github.head_ref != 'develop' | |
run: | | |
echo "Only the develop branch can be merged into the release branch." | |
exit 1 | |
- name: Enforce release/hotfix -> main | |
if: github.ref == 'refs/heads/main' && github.head_ref != 'release' && github.head_ref != 'hotfix' | |
run: | | |
echo "Only the release or hotfix branch can be merged into the main branch." | |
exit 1 |