forked from abhijeetps/weekly-digest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
24 lines (20 loc) · 1006 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const createScheduler = require('probot-scheduler');
const moment = require('moment');
const { INSTALLATION_EVENTS, INTERVAL, SCHEDULE_REPOSITORY_EVENT } = require('./src/bin/constants');
const { manageAppInstallation } = require('./src/bin/manageAppInstallation');
const { initCreateWeeklyDigest } = require('./src/bin/initCreateWeeklyDigest');
module.exports = (app) => {
app.log('Weekly Digest app is running successfully.');
app.on(INSTALLATION_EVENTS, async (context) => {
context.log.debug('Weekly Digest installed successfully.');
context.log.debug(`App is running as per ${context.event}`);
context.log.debug(`Local Time: ${moment().format()}`);
await manageAppInstallation(context);
});
createScheduler(app, { interval: INTERVAL });
app.on(SCHEDULE_REPOSITORY_EVENT, async (context) => {
context.log.debug('App is running as per schedule.repository');
context.log.debug(`Local Time: ${moment().format()}`);
await initCreateWeeklyDigest(context);
});
};