Skip to content

Commit

Permalink
fix cancelling jobs from different repos where two branches have the …
Browse files Browse the repository at this point in the history
…same name (#105)



Co-authored-by: Steven <steven@ceriously.com>
  • Loading branch information
spaceface777 and styfle committed Jul 29, 2021
1 parent b54f1a5 commit a66ae1f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion dist/index.js
Expand Up @@ -6122,6 +6122,7 @@ async function main() {
workflow_ids.push(String(current_run.workflow_id));
}
console.log(`Found workflow_id: ${JSON.stringify(workflow_ids)}`);
const trigger_repo_id = (payload.workflow_run || current_run).head_repository.id;
await Promise.all(workflow_ids.map(async (workflow_id) => {
try {
const { data: { total_count, workflow_runs }, } = await octokit.actions.listWorkflowRuns({
Expand All @@ -6139,7 +6140,8 @@ async function main() {
.reduce((a, b) => Math.max(a, b), cancelBefore.getTime());
cancelBefore = new Date(n);
}
const runningWorkflows = workflow_runs.filter(run => run.id !== current_run.id &&
const runningWorkflows = workflow_runs.filter(run => run.head_repository.id === trigger_repo_id &&
run.id !== current_run.id &&
(ignore_sha || run.head_sha !== headSha) &&
run.status !== 'completed' &&
new Date(run.created_at) < cancelBefore);
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Expand Up @@ -55,6 +55,7 @@ async function main() {
workflow_ids.push(String(current_run.workflow_id));
}
console.log(`Found workflow_id: ${JSON.stringify(workflow_ids)}`);
const trigger_repo_id = (payload.workflow_run || current_run).head_repository.id;
await Promise.all(
workflow_ids.map(async workflow_id => {
try {
Expand All @@ -78,6 +79,7 @@ async function main() {
}
const runningWorkflows = workflow_runs.filter(
run =>
run.head_repository.id === trigger_repo_id &&
run.id !== current_run.id &&
(ignore_sha || run.head_sha !== headSha) &&
run.status !== 'completed' &&
Expand Down

0 comments on commit a66ae1f

Please sign in to comment.