Skip to content

Commit

Permalink
fix(api): skipping dispatching new checks for in_progress checks (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
clearloop committed Jun 11, 2024
1 parent 0925fe2 commit 0e3c7ea
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
17 changes: 10 additions & 7 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 11 additions & 9 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ export default class Api {
// If the workflow has already been dispatched, create
// checks from the exist one.
let run = await this.latestRun(workflow_id, head_sha);
if (run) {
if (run.status !== 'completed') {
core.info(`The check is running in progress: ${run.html_url}`);
process.exit(0);
}

// Unset the run if it has got failed.
if (run.conclusion === 'failure') run = undefined;
}

if (!run) run = await this.dispatch(ref, workflow_id, inputs, head_sha);

// Create checks from the specifed jobs.
Expand Down Expand Up @@ -274,15 +284,7 @@ export default class Api {
);
});

const run = runs[0];

// Here we re-trigger a new workflow if the previous one
// is completed and failure.
if (run.status === 'completed' && run.conclusion === 'failure') {
return undefined;
}

return run;
return runs[0];
}

/**
Expand Down

0 comments on commit 0e3c7ea

Please sign in to comment.