diff --git a/.github/workflows/internal-tests.yml b/.github/workflows/internal-tests.yml index cd100558a69..d2529d6eaec 100644 --- a/.github/workflows/internal-tests.yml +++ b/.github/workflows/internal-tests.yml @@ -87,41 +87,17 @@ jobs: - name: Wait for Internal Tests to complete if: steps.filter.outputs.non_docs == 'true' - uses: actions/github-script@v7 - with: - github-token: ${{ secrets.SPACETIMEDB_PRIVATE_TOKEN }} - script: | - const targetOwner = process.env.TARGET_OWNER; - const targetRepo = process.env.TARGET_REPO; - const runId = Number(`${{ steps.dispatch.outputs.run_id }}`); - const runUrl = `${{ steps.dispatch.outputs.run_url }}`; - const sleep = (ms) => new Promise(r => setTimeout(r, ms)); - - core.info(`Waiting for workflow result... ${runUrl}`); - - let conclusion = null; - for (let attempt = 0; attempt < 240; attempt++) { // up to ~2 hours - const runResp = await github.rest.actions.getWorkflowRun({ - owner: targetOwner, - repo: targetRepo, - run_id: runId - }); - const { status, conclusion: c } = runResp.data; - if (status === 'completed') { - conclusion = c || 'success'; - break; - } - await sleep(30000); - } - - if (!conclusion) { - core.setFailed('Timed out waiting for private workflow to complete.'); - return; - } - - if (conclusion !== 'success') { - core.setFailed(`Private workflow failed with conclusion: ${conclusion}`); - } + env: + GH_TOKEN: ${{ secrets.SPACETIMEDB_PRIVATE_TOKEN }} + RUN_ID: ${{ steps.dispatch.outputs.run_id }} + RUN_URL: ${{ steps.dispatch.outputs.run_url }} + run: | + set -euo pipefail + echo "Waiting for workflow result... ${RUN_URL}" + gh run watch "$RUN_ID" \ + --repo "$TARGET_OWNER/$TARGET_REPO" \ + --exit-status \ + --interval 30 - name: Cancel invoked run if workflow cancelled if: ${{ cancelled() && steps.dispatch.outputs.run_id }}