diff --git a/.github/workflows/regen.yml b/.github/workflows/regen.yml index 06d314b4..2c404766 100644 --- a/.github/workflows/regen.yml +++ b/.github/workflows/regen.yml @@ -147,6 +147,7 @@ jobs: if [ "$(grep '^BREAKING CHANGE: ' <<< "$body")" = "$(grep '^BREAKING CHANGE: ' <<< "${prev-$body}" || true)" ]; then hold "carries breaking changes" quiet; fi hold "$(held "$1")" fi + refusal= for _ in $(seq 45); do sleep 60 # A PR merged into $base during the wait leaves this one behind, and the up-to-date rule refuses the merge until it takes that in. The new head's checks start over, so the run its Regen integration starts on completion merges it, with a full wait of its own. @@ -174,11 +175,18 @@ jobs: ''|queued/|in_progress/|waiting/|pending/|requested/) continue ;; *) echo "::warning::could not read the Regen integration run of #$num at $1: $run"; continue ;; esac - gh pr merge "$num" --squash --admin --match-head-commit "$1" && exit 0 ;; + refusal=$(gh pr merge "$num" --squash --admin --match-head-commit "$1" 2>&1 | sed -e 's/^GraphQL: //' -e 's/ (mergePullRequest)$//' -e 's/\.$//' | paste -sd ' ' -) && exit 0 + echo "$refusal" ;; *) echo "::warning::could not read the required checks of #$num: $checks" ;; esac done - human "did not merge within 45 minutes" + # One heads-up per head commit and reason: a later run that gives up on the same commit for the same reason, such as the daily one, finds the PR comment the first one left and stays quiet. Only the app's own comments count, so no one else can mute the heads-up. + reason=${refusal:+. GitHub says: $refusal} + marker="Did not merge $1 within 45 minutes$reason" + comments=$(gh pr view "$num" --json comments --jq '.comments[] | select(.author.login == env.APP_SLUG) | .body') || comments= + if grep -qxF "$marker" <<< "$comments"; then echo "::notice::#$num did not merge within 45 minutes, which an earlier run already reported for $1"; exit 0; fi + gh pr comment "$num" --body "$marker" || true + human "did not merge within 45 minutes$reason" exit 1 }