-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.js
46 lines (38 loc) · 1 KB
/
action.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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const yaml = require('yaml');
const { readFileSync } = require('fs');
const core = require('@actions/core');
const build = require('./lib/build');
const contextFileName = core.getInput('context');
const destinationDir = core.getInput('path');
const pagesDir = core.getInput('pages');
const themeDir = core.getInput('theme');
core.setOutput('html_path', destinationDir);
let context = {};
if (contextFileName) {
context = yaml.parse(readFileSync(contextFileName).toString());
}
if (!destinationDir) {
throw new Error('Destination directory is required');
}
if (!pagesDir) {
throw new Error('Pages directory is required');
}
if (!themeDir) {
throw new Error('Theme directory is required');
}
console.log(`HTML generated: ${destinationDir}`);
let params = {
context,
destinationDir,
pagesDir,
themeDir,
dateTimeFormat: 'DD.MM.YYYY',
};
build.start(params).then(
() => {
console.log('Generate: Done!');
},
(error) => {
core.setFailed(error.message);
}
);