Skip to content

Commit dfbe605

Browse files
authored
Improve logs (#53)
1 parent 277e407 commit dfbe605

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This includes runs with a [status](https://docs.github.com/en/rest/reference/che
66

77
## How does it work?
88

9-
When you `git push`, this GitHub Action will capture the current Branch and SHA. It will query GitHub's API to find previous workflow runs that match the Branch but do not match the SHA. These in-progress runs will be cancelled leaving only the latest run.
9+
When you `git push`, this GitHub Action will capture the current Branch and SHA. It will query GitHub's API to find previous workflow runs that match the Branch but do not match the SHA. These in-progress runs will be canceled leaving only the latest run.
1010

1111
Read more about the [Workflow Runs API](https://docs.github.com/en/rest/reference/actions#workflow-runs).
1212

Diff for: dist/index.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -5886,15 +5886,14 @@ async function main() {
58865886
branch,
58875887
});
58885888
const branchWorkflows = data.workflow_runs.filter(run => run.head_branch === branch);
5889-
console.log(`Found ${branchWorkflows.length} runs total for branch ${branch}.`);
5889+
console.log(`Found ${branchWorkflows.length} runs for workflow ${workflow_id} on branch ${branch}`);
58905890
console.log(branchWorkflows.map(run => `- ${run.html_url}`).join('\n'));
58915891
const runningWorkflows = branchWorkflows.filter(run => (ignore_sha || run.head_sha !== headSha) &&
58925892
run.status !== 'completed' &&
58935893
new Date(run.created_at) < new Date(current_run.created_at));
5894-
console.log(`Found ${runningWorkflows.length} runs to cancel.`);
5895-
console.log(runningWorkflows.map(run => `- ${run.html_url}`).join('\n'));
5896-
for (const { id, head_sha, status } of runningWorkflows) {
5897-
console.log('Cancelling another run: ', { id, head_sha, status });
5894+
console.log(`with ${runningWorkflows.length} runs to cancel.`);
5895+
for (const { id, head_sha, status, html_url } of runningWorkflows) {
5896+
console.log('Canceling run: ', { id, head_sha, status, html_url });
58985897
const res = await octokit.actions.cancelWorkflowRun({
58995898
owner,
59005899
repo,
@@ -5905,8 +5904,9 @@ async function main() {
59055904
}
59065905
catch (e) {
59075906
const msg = e.message || e;
5908-
console.log(`Error while cancelling workflow_id ${workflow_id}: ${msg}`);
5907+
console.log(`Error while canceling workflow_id ${workflow_id}: ${msg}`);
59095908
}
5909+
console.log('');
59105910
}));
59115911
}
59125912
main()

Diff for: src/index.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,18 @@ async function main() {
5757
});
5858

5959
const branchWorkflows = data.workflow_runs.filter(run => run.head_branch === branch);
60-
console.log(`Found ${branchWorkflows.length} runs total for branch ${branch}.`);
60+
console.log(`Found ${branchWorkflows.length} runs for workflow ${workflow_id} on branch ${branch}`);
6161
console.log(branchWorkflows.map(run => `- ${run.html_url}`).join('\n'));
6262

6363
const runningWorkflows = branchWorkflows.filter(run =>
6464
(ignore_sha || run.head_sha !== headSha) &&
6565
run.status !== 'completed' &&
6666
new Date(run.created_at) < new Date(current_run.created_at)
6767
);
68-
console.log(`Found ${runningWorkflows.length} runs to cancel.`);
69-
console.log(runningWorkflows.map(run => `- ${run.html_url}`).join('\n'));
68+
console.log(`with ${runningWorkflows.length} runs to cancel.`);
7069

71-
for (const {id, head_sha, status} of runningWorkflows) {
72-
console.log('Cancelling another run: ', {id, head_sha, status});
70+
for (const {id, head_sha, status, html_url} of runningWorkflows) {
71+
console.log('Canceling run: ', {id, head_sha, status, html_url});
7372
const res = await octokit.actions.cancelWorkflowRun({
7473
owner,
7574
repo,
@@ -79,8 +78,9 @@ async function main() {
7978
}
8079
} catch (e) {
8180
const msg = e.message || e;
82-
console.log(`Error while cancelling workflow_id ${workflow_id}: ${msg}`);
81+
console.log(`Error while canceling workflow_id ${workflow_id}: ${msg}`);
8382
}
83+
console.log('')
8484
}));
8585
}
8686

0 commit comments

Comments
 (0)