pr-target-branch-check.yml 721 B

123456789101112131415161718192021
  1. name: Check PR Branching Strategy
  2. on:
  3. pull_request:
  4. types: [opened, synchronize, reopened, edited]
  5. jobs:
  6. check-branching-strategy:
  7. runs-on: ubuntu-latest
  8. steps:
  9. - name: Enforce branching strategy
  10. run: |
  11. if [[ "${{ github.base_ref }}" == "main" ]]; then
  12. if [[ "${{ github.head_ref }}" != "alpha" ]]; then
  13. echo "Error: Pull requests to 'main' are only allowed from the 'alpha' branch."
  14. exit 1
  15. fi
  16. elif [[ "${{ github.base_ref }}" != "alpha" ]]; then
  17. echo "Error: Pull requests must be targeted to the 'alpha' or 'main' branch."
  18. exit 1
  19. fi
  20. echo "Branching strategy check passed."