From 376b569728f0547343eab09b76666aa2c9b16867 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Sun, 26 Mar 2023 18:39:00 +0100 Subject: [PATCH] Logging in release script delay + misc fixes --- .github/workflows/release.yml | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ef4885519..ad82c559f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -82,30 +82,44 @@ jobs: - name: "Wait for checks to pass" run: | - ${{ steps.commit.outputs.pushed }} - sha="${{ steps.commit.outputs.commit_long_sha }}" + pushed=${{ steps.commit.outputs.pushed }} + echo "Commit was pushed: ${pushed}" + $pushed + sha="${{ steps.commit.outputs.commit_long_sha }}" + echo "Pushed commit sha: ${sha}" + + echo "Waiting for PR head to sync" while [ "$new" != "$sha" ]; do sleep 1 new="$(curl -s "https://api.github.com/repos/${{ github.event.pull_request.base.repo.full_name }}/pulls/${{ github.event.pull_request.number }}" | jq -r ".head.sha")" + echo "New PR head sha: ${new}" done + echo "PR synced" - checks="$(curl -s "https://api.github.com/repos/${{ github.event.pull_request.base.repo.full_name }}/branches/main" | jq -r ".protection.required_status_checks.contexts[]")" + echo "Finding required status checks" + checks="$(curl -s "https://api.github.com/repos/${{ github.event.pull_request.base.repo.full_name }}/branches/${{ github.event.pull_request.base.ref }}" | jq -r ".protection.required_status_checks.contexts[]")" for check in $checks; do + echo "Started waiting for check: ${check}" found=false while ! $found; do sleep 1 - suites="$(curl -s "https://api.github.com/repos/${{ github.event.pull_request.head.repo.full_name }}/commits/${sha}/check-suites" | jq -r ".check_suites[].check_runs_url")" + echo "Querying check suites" + suites="$(curl -s "https://api.github.com/repos/${{ github.event.pull_request.head.repo.full_name }}/commits/${sha}/check-suites" | jq -r ".check_suites[].id")" for suite in $suites; do completed=false while ! $completed; do sleep 1 - run="$(curl -s "$suite" | jq -r '.check_runs[] | select(.name == "${check}")')" - [ "$run" != "" ] || continue 2 + echo "Querying check suite: ${suite}" + run="$(curl -s "https://api.github.com/repos/${{ github.event.pull_request.head.repo.full_name }}/check-suites/${suite}/check-runs" | jq -r '.check_runs[] | select(.name == "${check}")')" + [ "$run" != "" ] || (echo "Check suite ${suite} does not match check: ${check}" && continue 2) found=true - [ "$(echo "$run" | jq -r ".status")" = "completed" ] || continue + [ "$(echo "$run" | jq -r ".status")" = "completed" ] || (echo "Check suite ${suite} not complete yet" && sleep 10 && continue) completed=true - [ "$(echo "$run" | jq -r ".conclusion")" = "success" ] + echo "Check suite ${suite} completed" + [ "$(echo "$run" | jq -r ".conclusion")" = "success" ] || (echo "Check failed: ${check}" && false) + echo "Check passed: ${check}" + continue 3 done done done @@ -129,4 +143,4 @@ jobs: dist/${{ env.RELEASE_TAG }}.zip name: "${{ env.RELEASE_TAG }}" tag_name: "${{ env.RELEASE_TAG }}" - target_commitish: main + target_commitish: ${{ github.event.pull_request.base.ref }}