Skip to content

Commit

Permalink
Update status query strategy
Browse files Browse the repository at this point in the history
Signed-off-by: Joshua Castle <[email protected]>
  • Loading branch information
Kas-tle committed May 28, 2024
1 parent ac533b0 commit b2769bb
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions release/src/action/inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,22 @@ async function getSuccess(inp: {api: OctokitApi, repoData: Repo}): Promise<boole
const { owner, repo } = repoData;

const runID = process.env.GITHUB_RUN_ID!;
const statusResponse = await api.rest.actions.listJobsForWorkflowRun({ owner, repo, run_id: parseInt(runID) });
const success = statusResponse.data.jobs.filter(job => (job.steps ?? []).filter(step => step.conclusion === 'failure').length > 0 ).length === 0;
const runAttempt = process.env.GITHUB_RUN_ATTEMPT!;
const statusResponse = await api.rest.actions.listJobsForWorkflowRunAttempt({ owner, repo, run_id: parseInt(runID), attempt_number: parseInt(runAttempt)});
const jobs = statusResponse.data.jobs;
let success = true;

exit: for (const job of jobs) {
if (job.steps) {
for (const step of job.steps) {
if (step.conclusion === 'failure') {
success = false;
break exit;
}
}
}
}

console.log(`Workflow status is: ${success ? 'success' : 'failure'}`);

return success;
Expand Down

0 comments on commit b2769bb

Please sign in to comment.