Skip to content

Commit

Permalink
add: handle This workflow already running error
Browse files Browse the repository at this point in the history
  • Loading branch information
shqear93 committed Apr 27, 2024
1 parent 0fe3ac7 commit c2c882c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,16 @@ async function run() {
if (checkRun) {
const workflowId = checkRun.details_url.split('/').slice(-3)[0];

await octokit.rest.actions.reRunWorkflow({ owner, repo, run_id: workflowId });
console.info(`"${checkName}" workflow has been triggered again.`);
try {
await octokit.rest.actions.reRunWorkflow({ owner, repo, run_id: workflowId });
console.info(`"${checkName}" workflow has been triggered again.`);
} catch (error) {
if (error.message.includes('This workflow is already running')) {
console.warn(`"${checkName}" workflow is already running.`);
} else {
throw error;
}
}
} else {
console.info(`No "${checkName}" check found.`);
}
Expand Down

0 comments on commit c2c882c

Please sign in to comment.