From d852b7e8915939ce9fb747fb654a8447db30cf2f Mon Sep 17 00:00:00 2001 From: Lyon Till <158992+ljtill@users.noreply.github.com> Date: Mon, 10 May 2021 13:30:45 +0100 Subject: [PATCH] Update release.yml (#333) Fix release workflow with approval logic --- .github/workflows/release.yml | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fdee9f1f..781b24f6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -58,8 +58,24 @@ jobs: - name: "Merge" run: | - gh pr create --base 'main' --head 'release' --title 'Release v${{ steps.version.outputs.version }}' --body '' --label 'release :zap:' - gh pr merge 'release' --squash --delete-branch + gh pr create --base 'main' --head 'release' --title 'Release v${{ steps.version.outputs.version }}' --body '' --label 'release :zap:' --reviewer Azure/enterprisescale-vteam + COUNTER=0 + while : ; do + DECISION=$(gh pr status --json reviewDecision --jq '.currentBranch.reviewDecision') + if [ "$DECISION" == "APPROVED" ]; then + gh pr merge 'release' --squash --delete-branch + break + else + if [ $COUNTER -lt 300 ]; then + echo "Pending pull request approval - $COUNTER seconds" + sleep 30s + COUNTER=$(( $COUNTER + 30 )) + else + echo "Expired pull request approval" + exit 1 + fi + fi + done env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}