Squash & Merge button - restrict to some branches

Hello guys,

I want to configure the “Squash and Merge” button to be available on all branches, expect for the “release” branch. I normally squash my PRs and merge them using such a button in GitHub UI. But I found that sometimes I do it by mistake, and instead of the normal “Merge” - I use the “Squash and Merge” option (it’s critical when I need to merge all commits from the Master branch to the Release branch).

I want to restrict my repository to fail on the attempt of merging my PR against the “release” branch.

May I do it in pipeline, like I do when unit tests run to check if my PR is ready to merge. May I use the same technique to do some pre-checks when the “Merge” or “Squash and Merge” is initiated by user via GitHub UI?

Will be very beneficial to have such possibly.