Because it cancels pull request workflows after pushing new commits to PR branch
Since https://docs.github.com/en/actions/learn-github-actions/contexts#github-context says about github.ref "For workflows triggered by pull_request, this is the pull request merge branch." and "For other triggers, this is the branch or tag ref that triggered the workflow run.", and ". The ref given is fully-formed, meaning that for branches the format is refs/heads/, for pull requests it is refs/pull//merge" this should work (i.e. github.ref should not be the same for push and pull_request)
Because it cancels pull request workflows after pushing new commits to PR branch
Since https://docs.github.com/en/actions/learn-github-actions/contexts#github-context says about github.ref "For workflows triggered by pull_request, this is the pull request merge branch." and "For other triggers, this is the branch or tag ref that triggered the workflow run.", and ". The ref given is fully-formed, meaning that for branches the format is refs/heads/, for pull requests it is refs/pull//merge" this should work (i.e. github.ref should not be the same for push and pull_request)