A second label event on a PR whose first backport already merged
(for example backport-previous added shortly after backport merged)
re-enters the backport job for the target that already has the
change. The action's branch name for a backport is deterministic, so
that leg's cherry-pick is empty rather than conflicting, and git still
exits non-zero for an empty pick. Under this repository's
draft_commit_conflicts setting the action reads that exit code as a
conflict and tries to commit an empty working tree, which also fails
and surfaces as a false backport-failed comment on the original PR
for a branch the change has been on for a while.
Add a guard step that looks up whether a merged pull request already
exists on this target's deterministic backport branch, and skip the
checkout and the backport action for that leg when one does. The
guard changes nothing about the empty-cherry-pick behavior itself,
which lives in the action and needs a fix there; it only keeps a
known-stale re-run from reaching the action and misreporting.
Extend the existing backport.yaml contract tests with the new guard's
invariants: the merged (not merely closed) check on the deterministic
branch name, both downstream steps gated on the guard's output, and
step ordering.
Signed-off-by: Aleksei Sviridkin <f@lex.la>