Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix cancelling jobs from different repos where two branches have the same name #105

Merged
merged 4 commits into from Jul 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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