check-target.yml 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. name: Check target
  2. # Only release PRs (next -> main, from this repository) may target main.
  3. # Features, fixes and docs must target next. This runs on every PR so that it
  4. # can be a required status check; PRs that do not target main always pass.
  5. on:
  6. pull_request:
  7. types:
  8. - opened
  9. - reopened
  10. - synchronize
  11. - edited
  12. permissions: {}
  13. jobs:
  14. check-target:
  15. runs-on: ubuntu-latest
  16. steps:
  17. - name: Check target branch
  18. env:
  19. BASE_REF: ${{ github.event.pull_request.base.ref }}
  20. HEAD_REF: ${{ github.event.pull_request.head.ref }}
  21. HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }}
  22. THIS_REPO: ${{ github.repository }}
  23. run: |
  24. if [ "$BASE_REF" != "main" ]; then
  25. echo "PR targets '$BASE_REF', OK."
  26. exit 0
  27. fi
  28. if [ "$HEAD_REPO" = "$THIS_REPO" ] && [ "$HEAD_REF" = "next" ]; then
  29. echo "Release PR from next to main, OK."
  30. exit 0
  31. fi
  32. echo "::error title=Wrong target branch::Only release PRs from 'next' may target 'main'. Please edit this PR and change its base branch to 'next'."
  33. exit 1