name: Prevent pull request to main
on:
  pull_request_target:
    types:
      - opened
      - reopened
      - synchronize
      - edited

jobs:
  check-branches:
    runs-on: ubuntu-latest
    steps:
      - name: Check branches
        env:
          GITHUB_HEAD_REF: ${{ github.head_ref }}
          GITHUB_BASE_REF: ${{ github.base_ref }}
        run: |
          if [ "$GITHUB_HEAD_REF" != "development" ] && [ "$GITHUB_BASE_REF" == "main" ]; then
            echo "Create a pull request to quic/fastrpc:development branch"
            echo "Pull requests to quic/fastrpc:main branch are only allowed from quic/fastrpc:development branch."
            exit 1
          fi
