Skip to content

Commit

Permalink
fix: ignore inconsistent runs that have a status set to 'in_progress'…
Browse files Browse the repository at this point in the history
… but conclusion is 'success' (#59)

* Ignore inconsistent runs that have a status set to 'in_progress' but conclusion is 'success'

* Bump action node version to 16

* Upgrade dependencies, run npm dedupe

* run fmt and build

Signed-off-by: Rui Chen <[email protected]>

---------

Signed-off-by: Rui Chen <[email protected]>
Co-authored-by: gustaff-weldon <[email protected]>
  • Loading branch information
chenrui333 and gustaff-weldon authored Jun 19, 2024
1 parent 63921e5 commit df7e268
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ async function run() {
try {
const input = parseInput(env);
debug(
`Parsed inputs (w/o token): ${(({ githubToken, ...inputs }) => inputs)(
input,
)}`,
`Parsed inputs (w/o token): ${(({ githubToken, ...inputs }) =>
JSON.stringify(inputs))(input)}`,
);
const github = new OctokitGitHub(input.githubToken);
debug(`Fetching workflows for ${input.owner}/${input.repo}...`);
Expand Down
11 changes: 11 additions & 0 deletions src/wait.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ export class Waiter implements Wait {
this.debug(`Found ${runs.length} ${this.workflowId} runs`);
const previousRuns = runs
.filter((run) => run.id < this.input.runId)
.filter((run) => {
const isSuccessful: boolean = run.conclusion === "success";

if (isSuccessful) {
this.debug(
`Skipping run ${run.id}, status: ${run.status}, conclusion: ${run.conclusion}`,
);
}

return !isSuccessful;
})
.sort((a, b) => b.id - a.id);
if (!previousRuns || !previousRuns.length) {
setOutput("force_continued", "");
Expand Down

0 comments on commit df7e268

Please sign in to comment.