From 6274c18b75c07fefcd05bb76510289ea87c14515 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulises=20Gasc=C3=B3n?= Date: Thu, 18 Apr 2024 16:12:44 +0200 Subject: [PATCH] ci: add extended repository dispatch --- .github/workflows/integration-tests.yml | 28 +++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 57c20cb2f8..48b92e7caa 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -22,9 +22,25 @@ jobs: fi - name: Repository Dispatch - uses: peter-evans/repository-dispatch@ff45666b9427631e3450c54a1bcbee4d9ff4d7c0 # v3.0.0 - with: - token: "${{ secrets.PAT_INTEGRATION_TESTS}}" - repository: expressjs/examples - event-type: integration-tests - client-payload: '{"branch": "${{ steps.get_branch.outputs.branch }}", "repo": "${{ steps.get_repo.outputs.repo }}"}' \ No newline at end of file + env: + TOKEN: ${{ secrets.PAT_INTEGRATION_TESTS }} + run: | + response=$(curl -X POST https://api.github.com/repos/expressjs/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