Create enforce-branch-order.yml #1
Workflow file for this run
This file contains hidden or 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
| on: | |
| pull_request: | |
| types: [opened, edited, reopened] | |
| jobs: | |
| check-merge-order: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Validate Merge Order | |
| run: | | |
| BASE_BRANCH="${{ github.event.pull_request.base.ref }}" | |
| HEAD_BRANCH="${{ github.event.pull_request.head.ref }}" | |
| if [ "$BASE_BRANCH" == "main" ]; then | |
| if [ "$HEAD_BRANCH" != "staging" ]; then | |
| echo "Error: Pull requests to main must come from the staging branch." | |
| exit 1 | |
| fi | |
| elif [ "$BASE_BRANCH" == "staging" ]; then | |
| if [ "$HEAD_BRANCH" != "dev" ]; then | |
| echo "Error: Pull requests to staging must come from the dev branch." | |
| exit 1 | |
| fi | |
| fi | |
| echo "Branch merge order validated: $HEAD_BRANCH -> $BASE_BRANCH" |