ci: fix conditional skip and add safeguard
Adopt a third-party action to avoid script bugs, and to fix a current
issue where the script fails to detect all changes when processing push
events on PR branches.
Adapted from hashicorp/consul-dataplane#637. See that PR for testing
details and background context.