From 3c77eb0e1bb8fca2fe657466f3ba84541728775e Mon Sep 17 00:00:00 2001 From: Titus Kirch Date: Sat, 5 Sep 2026 17:04:08 +0200 Subject: [PATCH] fix(promotion-pr): treat nothing to promote as success (#30) --- .github/workflows/_promotion-pr.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 \