Skip to content

Commit

Permalink
Create usetrace-utils.js
Browse files Browse the repository at this point in the history
  • Loading branch information
dservidie authored Jul 2, 2024
1 parent 7b607a0 commit 15fa824
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/usetrace-utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const github = require('@actions/github');
const core = require('@actions/core');

async function sleep(ms) {
return 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
}
}

module.exports = { pollStatus };

0 comments on commit 15fa824

Please sign in to comment.