Skip to content

Commit

Permalink
revert(api): revert re-trigger logic (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
clearloop committed Jun 11, 2024
1 parent 0925fe2 commit f2c8910
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 22 deletions.
31 changes: 21 additions & 10 deletions dist/index.js

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

34 changes: 22 additions & 12 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,21 @@ 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) {
// NOTE:
//
// The sorting of workflow runs may have problem,
// revert this logic atm.
//
// 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 @@ -152,13 +167,16 @@ export default class Api {
status: 'in_progress',
output: {
title: name,
summary: `Forked from ${run.html_url}\nRe-run the \`${github.context.job}\` job in ${sourceHtml()} to re-trigger this check.`
summary: `Forked from ${run.html_url}`
// TODO:
//
// summary: `Forked from ${run.html_url}\nRe-run the \`${github.context.job}\` job in ${sourceHtml()} to re-trigger this check.`
},
head_sha
});

core.debug(`Created check ${data}.`);
core.info(`Created check ${data.name} at ${data.html_url}.`);
core.info(`Created check ${data.name} at ${data.html_url}`);
return data;
}

Expand Down Expand Up @@ -192,7 +210,7 @@ export default class Api {
}

core.debug(`Latest run: ${JSON.stringify(run, null, 2)}.`);
core.info(`Dispatched workflow ${run.html_url}.`);
core.info(`Dispatched workflow ${run.html_url} .`);
return run;
}

Expand Down Expand Up @@ -274,15 +292,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 f2c8910

Please sign in to comment.