name: Prevent prod to staging merges

on:
  pull_request:
    branches: staging

jobs:
  check-branch:
    runs-on: ubuntu-latest
    steps:
    - name: Fail if we are merging prod to staging
      run: |
        echo $GITHUB_HEAD_REF | grep -v prod
name: Prevent prod to staging merges

on:
  pull_request:
    branches: 
    - staging
    - prod

jobs:
  check-branch:
    runs-on: ubuntu-latest
    steps:
    - name: Only allow staging -> prod merges
      run: |
        # All branches *except* prod can be merged into staging
        # *Only* staging can be merged into prod
        python3 -c 'import os, sys; sys.exit(not(os.environ["GITHUB_HEAD_REF"] == "staging" if os.environ["GITHUB_BASE_REF"] == "prod" else os.environ["GITHUB_HEAD_REF"] != "prod"))'
Extend check for allowed merges
Extend check for allowed merges

- Only staging can be merged into prod
- Anything *except* prod can be merged into staging
