From d54fbd96ccfb8d406d11f850ab7dfd7ecb35f743 Mon Sep 17 00:00:00 2001 From: Digikwal <79085106+digikwal@users.noreply.github.com> Date: Thu, 26 Jun 2025 17:14:42 +0200 Subject: [PATCH] ci: Add reusable wait-for-check workflow to safely trigger release Introduces a reusable workflow that waits until the 'Check' workflow has successfully passed on the current commit. Also adds 'release-trigger', which runs on push to main and calls this reusable workflow before allowing semantic-release to continue. - Prevents race conditions between quality checks and release - No external dependencies (uses native GitHub CLI) - Improves reliability and control of CI/CD sequencing --- .github/workflows/wait-for-check.yml | 52 ++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/wait-for-check.yml diff --git a/.github/workflows/wait-for-check.yml b/.github/workflows/wait-for-check.yml new file mode 100644 index 00000000..4d6b5e7a --- /dev/null +++ b/.github/workflows/wait-for-check.yml @@ -0,0 +1,52 @@ +name: Wait for Check Workflow + +on: + workflow_call: + inputs: + sha: + required: true + type: string + secrets: + GH_TOKEN: + required: true + +jobs: + wait-for-check: + runs-on: ubuntu-latest + + steps: + - name: Wait for Check workflow to succeed + env: + GH_TOKEN: ${{ secrets.GH_TOKEN }} + SHA: ${{ inputs.sha }} + run: | + echo "🔁 Waiting for 'Check' workflow to succeed on commit $SHA..." + + max_attempts=30 + attempt=1 + interval=10 + success=false + + while [ $attempt -le $max_attempts ]; do + echo "Attempt $attempt..." + status=$(gh run list --workflow "Check" --limit 1 --json status,conclusion,headSha -q \ + 'map(select(.headSha=="'"$SHA"'")) | .[0] | "\(.status)-\(.conclusion)"') + + if [[ "$status" == "completed-success" ]]; then + echo "✅ Check passed." + success=true + break + elif [[ "$status" == completed-* ]]; then + echo "❌ Check completed but failed." + exit 1 + else + echo "⏳ Still in progress..." + sleep $interval + ((attempt++)) + fi + done + + if [[ "$success" == false ]]; then + echo "❌ Timeout: Check workflow did not complete in time." + exit 1 + fi