in src/glitch/wakeup.js [36:54]
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;
}
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
if (Date.now() - lastFailedTs >= 60 * 60 * 1e3) {
lastNoticedWorkflowRunId = latestFailedRun.id;
return true;
}
return false;
}