diff --git a/.github/workflows/_promotion-pr.yml b/.github/workflows/_promotion-pr.yml index 757acb7..69e0fdc 100644 --- a/.github/workflows/_promotion-pr.yml +++ b/.github/workflows/_promotion-pr.yml @@ -118,6 +118,18 @@ jobs: exit 0 fi + # Nothing to promote is a normal state, not a failure. It happens on a + # repo whose `dev` was just cut from `main`, and after any push that + # adds no commit `main` lacks — a sync merge of `main` back into `dev`, + # most often. `gh pr create` answers that with `GraphQL: No commits + # between main and dev` and a non-zero exit, so the job has to ask + # first: comparing the two refs is one API call and says exactly this. + ahead=$(gh api "repos/$GH_REPO/compare/$TARGET...$SOURCE" --jq '.ahead_by') + if [ "$ahead" -eq 0 ]; then + echo "'$SOURCE' carries no commits '$TARGET' lacks — nothing to promote." + exit 0 + fi + # `gh pr create` has no --json; it prints the PR URL, whose last # path segment is the number. url=$(gh pr create \