Skip to content

Commit

Permalink
Update github-actions-usetrace-integration-test.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
dservidie authored Jul 2, 2024
1 parent 71381fc commit 20bd869
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions .github/workflows/github-actions-usetrace-integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ jobs:
test-usetrace-webhook:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Trigger Usetrace Webhook and Poll Status
uses: actions/github-script@v6
env:
Expand All @@ -20,7 +17,31 @@ jobs:
TRACE_ID: ${{ vars.USETRACE_TRACE_ID }}
with:
script: |
const { pollStatus } = require('./usetrace-utils.js');
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
async function pollStatus(octokit, buildId, apiKey) {
while (true) {
try {
const statusResponse = await octokit.request('GET https://api.usetrace.com/api/build/{build_id}/status', {
build_id: buildId,
headers: {
'Authorization': `Bearer ${apiKey}`
}
});
if (statusResponse.status !== 404) {
console.log('Build status:', statusResponse.data);
return statusResponse.data;
}
} catch (error) {
if (error.status !== 404) {
throw error;
}
}
await sleep(1000); // Wait for 1 second before next poll
}
}
try {
const response = await github.request('POST https://api.usetrace.com/api/trace/{trace_id}/execute', {
Expand Down

0 comments on commit 20bd869

Please sign in to comment.