Skip to content

Commit 867de26

Browse files
authored
Compare workflows by run number instead of creation date (#116)
* compare workflows by run number instead of creation date * commit compiled js
1 parent 98d1dc8 commit 867de26

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

dist/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -9911,6 +9911,7 @@ function parseWorkflowRun(run) {
99119911
runId: run.id,
99129912
workflowId,
99139913
createdAt: run.created_at,
9914+
runNumber: run.run_number,
99149915
};
99159916
}
99169917
function parseAllRuns(response) {
@@ -10071,7 +10072,7 @@ function detectConcurrentRuns(context) {
1007110072
exitSuccess({ shouldSkip: true });
1007210073
}
1007310074
else if (context.concurrentSkipping === "same_content_newer") {
10074-
const concurrentIsOlder = concurrentRuns.find((run) => new Date(run.createdAt).getTime() < new Date(context.currentRun.createdAt).getTime());
10075+
const concurrentIsOlder = concurrentRuns.find((run) => run.runNumber < context.currentRun.runNumber);
1007510076
if (concurrentIsOlder) {
1007610077
core.info(`Skip execution because the exact same files are concurrently checked in older ${concurrentDuplicate.html_url}`);
1007710078
exitSuccess({ shouldSkip: true });

src/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ interface WorkflowRun {
3333
runId: number;
3434
workflowId: number;
3535
createdAt: string;
36+
runNumber: number;
3637
}
3738

3839
type WRunTrigger = "pull_request" | "push" | "workflow_dispatch" | "schedule";
@@ -70,6 +71,7 @@ function parseWorkflowRun(run: ActionsGetWorkflowRunResponseData): WorkflowRun {
7071
runId: run.id,
7172
workflowId,
7273
createdAt: run.created_at,
74+
runNumber: run.run_number,
7375
}
7476
}
7577

@@ -235,7 +237,7 @@ function detectConcurrentRuns(context: WRunContext) {
235237
core.info(`Skip execution because the exact same files are concurrently checked in ${concurrentDuplicate.html_url}`);
236238
exitSuccess({ shouldSkip: true });
237239
} else if (context.concurrentSkipping === "same_content_newer") {
238-
const concurrentIsOlder = concurrentRuns.find((run) => new Date(run.createdAt).getTime() < new Date(context.currentRun.createdAt).getTime());
240+
const concurrentIsOlder = concurrentRuns.find((run) => run.runNumber < context.currentRun.runNumber);
239241
if (concurrentIsOlder) {
240242
core.info(`Skip execution because the exact same files are concurrently checked in older ${concurrentDuplicate.html_url}`);
241243
exitSuccess({ shouldSkip: true });

0 commit comments

Comments
 (0)