Skip to content

Commit

Permalink
fix: use the wait script from core
Browse files Browse the repository at this point in the history
  • Loading branch information
naftis committed Nov 19, 2024
1 parent 614450d commit da5915a
Showing 1 changed file with 32 additions and 24 deletions.
56 changes: 32 additions & 24 deletions .github/workflows/deploy-to-feature-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,31 +80,39 @@ jobs:
| jq -r '.workflow_runs[0].id')
echo "run_id=$RUN_ID" >> $GITHUB_OUTPUT
- name: Poll workflow status
env:
RUN_ID: ${{ steps.get-run-id.outputs.run_id }}
GITHUB_TOKEN: ${{ secrets.OLLIE_BOT_GITHUB_TOKEN }}
run: |
STATUS="in_progress"
- name: Wait for E2E Workflow Completion
uses: actions/github-script@v7
with:
github-token: ${{ secrets.OLLIE_BOT_GITHUB_TOKEN }}
script: |
const owner = 'opencrvs';
const repo = 'e2e';
const runId = ${{ steps.get-run-id.outputs.run_id }};
let status = 'in_progress';
while [[ "$STATUS" == "in_progress" || "$STATUS" == "queued" ]]; do
STATUS=$(curl -H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/opencrvs/e2e/actions/runs/$RUN_ID" \
| jq -r '.status')
echo "Workflow run status: $STATUS"
[[ "$STATUS" == "completed" ]] && break
sleep 10
done
while (status === 'in_progress' || status === 'queued') {
const run = await github.rest.actions.getWorkflowRun({
owner,
repo,
run_id: runId
});
CONCLUSION=$(curl -H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/opencrvs/e2e/actions/runs/$RUN_ID" \
| jq -r '.conclusion')
status = run.data.status;
console.log(`Current status: ${status}`);
if [[ "$CONCLUSION" != "success" ]]; then
echo "Workflow run failed with conclusion: $CONCLUSION"
exit 1
fi
if (status === 'in_progress' || status === 'queued') {
await new Promise(resolve => setTimeout(resolve, 10000));
}
}
echo "Workflow run succeeded!"
if (status === 'completed') {
const conclusion = await github.rest.actions.getWorkflowRun({
owner,
repo,
run_id: runId
});
console.log(`Workflow finished with conclusion: ${conclusion.data.conclusion}`);
if (conclusion.data.conclusion !== 'success') {
throw new Error('E2E workflow failed');
}
}

0 comments on commit da5915a

Please sign in to comment.