This is an automated email from the ASF dual-hosted git repository.
wangzx pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/echarts-bot.git
The following commit(s) were added to refs/heads/master by this push:
new acbdd8b fix(glitch): skip notification for the same workflow run
acbdd8b is described below
commit acbdd8b07543cd56a11a8078173e20605d78d713
Author: plainheart <[email protected]>
AuthorDate: Sat Nov 18 17:27:30 2023 +0800
fix(glitch): skip notification for the same workflow run
---
src/glitch/wakeup.js | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/glitch/wakeup.js b/src/glitch/wakeup.js
index 5974804..b134063 100644
--- a/src/glitch/wakeup.js
+++ b/src/glitch/wakeup.js
@@ -31,14 +31,24 @@ const WAKEUP_URL =
'https://apache-incubator-echarts-bot-1.glitch.me/probot';
}
})();
+let lastNoticedWorkflowRunId;
+
async function isNotificationNeeded() {
const failedActionRuns = await
fetch('https://api.github.com/repos/apache/echarts-bot/actions/workflows/8490751/runs?status=failure&per_page=1')
.then(res => res.json());
const latestFailedRun = failedActionRuns.workflow_runs[0];
if (!latestFailedRun) {
- return true
+ return true;
+ }
+ if (latestFailedRun.id === lastNoticedWorkflowRunId) {
+ console.log('skip notification for the same workflow run:',
lastNoticedWorkflowRunId);
+ return false;
}
const lastFailedTs = Date.parse(latestFailedRun.run_started_at);
// send notification when the failure last for one hour and more
- return Date.now() - lastFailedTs >= 60 * 60 * 1e3;
+ if (Date.now() - lastFailedTs >= 60 * 60 * 1e3) {
+ lastNoticedWorkflowRunId = latestFailedRun.id;
+ return true;
+ }
+ return false;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]