From c98f3cb2cd23fba50e29480267b75ee45641d1f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulises=20Gasc=C3=B3n?= Date: Thu, 18 Apr 2024 16:20:52 +0200 Subject: [PATCH] fix: add sleep step --- .github/workflows/integration-tests.yml | 51 ++++++++++++++----------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 3489b6527f..f944c69d32 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -21,26 +21,31 @@ jobs: echo "repo=${{ github.repository }}" >> $GITHUB_OUTPUT fi - - name: Repository Dispatch - env: - TOKEN: ${{ secrets.PAT_INTEGRATION_TESTS }} - run: | - response=$(curl -X POST https://api.github.com/repos/UlisesGascon/express-examples/dispatches \ - -H 'Accept: application/vnd.github.everest-preview+json' \ - -H "Authorization: token $TOKEN" \ - --data '{"event_type": "integration-tests", "client_payload": {"branch": "${{ steps.get_branch.outputs.branch }}", "repo": "${{ steps.get_repo.outputs.repo }}"}}') - - workflow_url=$(echo "$response" | jq -r .url) - - status="" - while [[ "$status" != "completed" ]]; do - sleep 10 - response=$(curl -H "Authorization: token $TOKEN" $workflow_url) - status=$(echo "$response" | jq -r .status) - done - - conclusion=$(echo "$response" | jq -r .conclusion) - if [[ "$conclusion" != "success" ]]; then - echo "Workflow failed" - exit 1 - fi \ No newline at end of file + - name: Repository Dispatch + env: + TOKEN: ${{ secrets.PAT_INTEGRATION_TESTS }} + run: | + curl -X POST https://api.github.com/repos/UlisesGascon/express-examples/dispatches \ + -H 'Accept: application/vnd.github.everest-preview+json' \ + -H "Authorization: token $TOKEN" \ + --data '{"event_type": "integration-tests", "client_payload": {"branch": "${{ steps.get_branch.outputs.branch }}", "repo": "${{ steps.get_repo.outputs.repo }}"}}' + + # Wait for the workflow to start + sleep 60 + + # Get the latest workflow run + response=$(curl -H "Authorization: token $TOKEN" https://api.github.com/repos/UlisesGascon/express-examples/actions/runs) + workflow_url=$(echo "$response" | jq -r '.workflow_runs[0].url') + + status="" + while [[ "$status" != "completed" ]]; do + sleep 10 + response=$(curl -H "Authorization: token $TOKEN" $workflow_url) + status=$(echo "$response" | jq -r .status) + done + + conclusion=$(echo "$response" | jq -r .conclusion) + if [[ "$conclusion" != "success" ]]; then + echo "Workflow failed" + exit 1 + fi \ No newline at end of file