chore: CI: have restart-on-label wait for the cancelled run before restarting it (#15121)

Polls until the run this job just cancelled reports `completed`, rather
than sleeping a fixed 30 seconds. `gh run rerun` refuses a run that is
still live with "This workflow is already running", so when the
cancellation took longer than the sleep the job failed and the restart
never happened, leaving the pull request with a cancelled CI run and a
red check. Also exits early when no run matches the head commit, instead
of passing an empty id to `gh run view`.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
1 file changed