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
| name: Protect main from unauthorized merges | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| restrict-main-source: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Validate PR source branch | |
| run: | | |
| SRC="${{ github.head_ref }}" | |
| echo "PR opened from: $SRC" | |
| # Allowed sources | |
| if [[ "$SRC" == "staging" ]] || [[ "$SRC" == hotfix/* ]]; then | |
| echo "✔ Allowed branch for merging into main." | |
| exit 0 | |
| fi | |
| echo "❌ PRs into main must come from 'staging' or 'hotfix/*'." | |
| exit 1 |