Skip to content

Commit 277e407

Browse files
authored
Add more details to logs (#51)
1 parent 99e363e commit 277e407

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

Diff for: dist/index.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -5885,12 +5885,14 @@ async function main() {
58855885
workflow_id,
58865886
branch,
58875887
});
5888-
console.log(`Found ${data.total_count} runs total.`);
5889-
const runningWorkflows = data.workflow_runs.filter(run => run.head_branch === branch &&
5890-
(ignore_sha || run.head_sha !== headSha) &&
5888+
const branchWorkflows = data.workflow_runs.filter(run => run.head_branch === branch);
5889+
console.log(`Found ${branchWorkflows.length} runs total for branch ${branch}.`);
5890+
console.log(branchWorkflows.map(run => `- ${run.html_url}`).join('\n'));
5891+
const runningWorkflows = branchWorkflows.filter(run => (ignore_sha || run.head_sha !== headSha) &&
58915892
run.status !== 'completed' &&
58925893
new Date(run.created_at) < new Date(current_run.created_at));
5893-
console.log(`Found ${runningWorkflows.length} runs in progress.`);
5894+
console.log(`Found ${runningWorkflows.length} runs to cancel.`);
5895+
console.log(runningWorkflows.map(run => `- ${run.html_url}`).join('\n'));
58945896
for (const { id, head_sha, status } of runningWorkflows) {
58955897
console.log('Cancelling another run: ', { id, head_sha, status });
58965898
const res = await octokit.actions.cancelWorkflowRun({

Diff for: src/index.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,19 @@ async function main() {
5555
workflow_id,
5656
branch,
5757
});
58-
console.log(`Found ${data.total_count} runs total.`);
59-
const runningWorkflows = data.workflow_runs.filter(run =>
60-
run.head_branch === branch &&
58+
59+
const branchWorkflows = data.workflow_runs.filter(run => run.head_branch === branch);
60+
console.log(`Found ${branchWorkflows.length} runs total for branch ${branch}.`);
61+
console.log(branchWorkflows.map(run => `- ${run.html_url}`).join('\n'));
62+
63+
const runningWorkflows = branchWorkflows.filter(run =>
6164
(ignore_sha || run.head_sha !== headSha) &&
6265
run.status !== 'completed' &&
6366
new Date(run.created_at) < new Date(current_run.created_at)
6467
);
65-
console.log(`Found ${runningWorkflows.length} runs in progress.`);
68+
console.log(`Found ${runningWorkflows.length} runs to cancel.`);
69+
console.log(runningWorkflows.map(run => `- ${run.html_url}`).join('\n'));
70+
6671
for (const {id, head_sha, status} of runningWorkflows) {
6772
console.log('Cancelling another run: ', {id, head_sha, status});
6873
const res = await octokit.actions.cancelWorkflowRun({

0 commit comments

Comments
 (0)