-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
46 lines (37 loc) · 1.46 KB
/
index.js
File metadata and controls
46 lines (37 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
if (process.env.NODE_ENV === 'development') {
require('dotenv').config();
}
const path = require('path');
const core = require('@actions/core');
// Action Handlers
const generateScreenshots = require('./src/action-handlers/generate-screenshots');
const downloadScreenshots = require('./src/action-handlers/download-screenshots');
const collectGatsbyUrls = require('./src/action-handlers/collect-static-gatsby-urls');
const generateHTML = require('./src/action-handlers/generate-html');
const collectSitemapUrls = require('./src/action-handlers/collect-sitemap-urls');
const slackPost = require('./src/action-handlers/slack-post');
const ACTION_HANDLERS = {
'generate-screenshots': generateScreenshots,
'download-screenshots': downloadScreenshots,
'collect-static-gatsby': collectGatsbyUrls,
'generate-html': generateHTML,
'collect-sitemap-urls': collectSitemapUrls,
'slack-post': slackPost,
};
(async () => {
try {
const action = process.env.NODE_ENV === 'development'
? process.env.ACTION
: core.getInput('action');
console.log('Current dir: ', path.dirname(__filename));
console.log('Action', action)
const actionHandler = ACTION_HANDLERS[action];
if (!actionHandler) {
const possibleActions = Object.keys(ACTION_HANDLERS).join(', ');
throw new Error(`ActionHandler not found: ${action} possible actions: [${possibleActions}] `);
}
await actionHandler();
} catch (error) {
core.setFailed(error.message);
}
})();