diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index 1bfe1234c..be1625811 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -54,9 +54,7 @@ jobs: function prCheck () { REPO=$1 BASE=$2 - STATE=$(gh pr list --repo $GITHUB_REPOSITORY_OWNER/$REPO --json title,mergeStateStatus,state,reviews \ - --state OPEN --base $BASE --head $RELEASE_BRANCH \ - --jq '.[] | select(.mergeStateStatus == "CLEAN") | .reviews | max_by(.submittedAt) | .state') + STATE=$(gh pr list --repo $GITHUB_REPOSITORY_OWNER/$REPO --json title,mergeStateStatus,state,reviews --state OPEN --base $BASE --head $RELEASE_BRANCH --jq '.[] | select(.mergeStateStatus == "CLEAN" and .reviews[-1].state == "APPROVED") | .reviews[-1].state') if [ "$STATE" != "APPROVED" ]; then echo "Error: PR for merging $GITHUB_REPOSITORY_OWNER/$REPO $RELEASE_BRANCH into $BASE needs to be ready to merge and approved. (STATE=$STATE)" >&2 exit 1