diff --git a/dist/index.js b/dist/index.js index a0b1cd7b..b8a3bf29 100644 --- a/dist/index.js +++ b/dist/index.js @@ -5908,15 +5908,21 @@ async function main() { } async function cancelWorkflowRuns(runningWorkflows, owner, repo, token) { const octokit = github.getOctokit(token); + const promises = []; for (const { id, head_sha, status, html_url } of runningWorkflows) { console.log('Canceling run: ', { id, head_sha, status, html_url }); - const res = await octokit.actions.cancelWorkflowRun({ + const current_promise = octokit.actions + .cancelWorkflowRun({ owner, repo, run_id: id + }) + .then(res => { + console.log(`Cancel run ${id} responded with status ${res.status}`); }); - console.log(`Cancel run ${id} responded with status ${res.status}`); + promises.push(current_promise); } + await Promise.all(promises); } main() .then(() => core.info('Cancel Complete.')) diff --git a/src/index.ts b/src/index.ts index ba9eb5f7..7f927e9a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -96,16 +96,21 @@ async function cancelWorkflowRuns( token: string ): Promise { const octokit = github.getOctokit(token); - + const promises = []; for (const { id, head_sha, status, html_url } of runningWorkflows) { console.log('Canceling run: ', { id, head_sha, status, html_url }); - const res = await octokit.actions.cancelWorkflowRun({ - owner, - repo, - run_id: id - }); - console.log(`Cancel run ${id} responded with status ${res.status}`); + const current_promise = octokit.actions + .cancelWorkflowRun({ + owner, + repo, + run_id: id + }) + .then(res => { + console.log(`Cancel run ${id} responded with status ${res.status}`); + }); + promises.push(current_promise); } + await Promise.all(promises); } main()