Skip to content

Commit a66ae1f

Browse files
spaceface777styfle
andauthored
fix cancelling jobs from different repos where two branches have the same name (#105)
Co-authored-by: Steven <steven@ceriously.com>
1 parent b54f1a5 commit a66ae1f

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

dist/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -6122,6 +6122,7 @@ async function main() {
61226122
workflow_ids.push(String(current_run.workflow_id));
61236123
}
61246124
console.log(`Found workflow_id: ${JSON.stringify(workflow_ids)}`);
6125+
const trigger_repo_id = (payload.workflow_run || current_run).head_repository.id;
61256126
await Promise.all(workflow_ids.map(async (workflow_id) => {
61266127
try {
61276128
const { data: { total_count, workflow_runs }, } = await octokit.actions.listWorkflowRuns({
@@ -6139,7 +6140,8 @@ async function main() {
61396140
.reduce((a, b) => Math.max(a, b), cancelBefore.getTime());
61406141
cancelBefore = new Date(n);
61416142
}
6142-
const runningWorkflows = workflow_runs.filter(run => run.id !== current_run.id &&
6143+
const runningWorkflows = workflow_runs.filter(run => run.head_repository.id === trigger_repo_id &&
6144+
run.id !== current_run.id &&
61436145
(ignore_sha || run.head_sha !== headSha) &&
61446146
run.status !== 'completed' &&
61456147
new Date(run.created_at) < cancelBefore);

src/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ async function main() {
5555
workflow_ids.push(String(current_run.workflow_id));
5656
}
5757
console.log(`Found workflow_id: ${JSON.stringify(workflow_ids)}`);
58+
const trigger_repo_id = (payload.workflow_run || current_run).head_repository.id;
5859
await Promise.all(
5960
workflow_ids.map(async workflow_id => {
6061
try {
@@ -78,6 +79,7 @@ async function main() {
7879
}
7980
const runningWorkflows = workflow_runs.filter(
8081
run =>
82+
run.head_repository.id === trigger_repo_id &&
8183
run.id !== current_run.id &&
8284
(ignore_sha || run.head_sha !== headSha) &&
8385
run.status !== 'completed' &&

0 commit comments

Comments
 (0)