-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
68 lines (64 loc) · 2.13 KB
/
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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const path = require('path');
const core = require('@actions/core');
const github = require('@actions/github');
const { execSync } = require('child_process');
const { run } = require('./lib/');
const CWD = execSync('pwd').toString('utf8').trim();
const TEMPLATES = path.join(__dirname, 'templates');
// No shorthand for TEMPLATES, because otherwise `ncc build` fails...
const paths = { CWD, TEMPLATES: TEMPLATES };
const token = core.getInput('repo-token', { required: true });
const url = core.getInput('url', { required: true });
const title = core.getInput('title');
const description = core.getInput('description');
const theme = core.getInput('theme');
const dateFormat = core.getInput('date-format');
const postsPerPage = core.getInput('posts-per-page');
const customStyles = core.getInput('custom-styles');
const customJavascript = core.getInput('custom-javascript');
const pages = core.getInput('pages');
const staticFrontpage = core.getInput('static-frontpage');
const label = core.getInput('label');
const closed = core.getInput('closed');
const outDir = core.getInput('out-dir');
const staticDir = core.getInput('static-dir');
const lang = core.getInput('lang');
const i18nNext = core.getInput('i18n.next');
const i18nPrev = core.getInput('i18n.prev');
const i18nPosts = core.getInput('i18n.posts');
const i18n = {
next: i18nNext,
prev: i18nPrev,
posts: i18nPosts,
};
const { repo } = github.context;
const octokit = github.getOctokit(token);
const userOptions = {
url,
lang,
i18n,
theme,
dateFormat,
postsPerPage,
pages,
outDir,
staticDir,
...(title ? { title } : undefined),
...(description ? { description } : undefined),
...(customStyles
? { customStyles: path.resolve(CWD, customStyles) }
: undefined),
...(customJavascript
? { customJavascript: path.resolve(CWD, customJavascript) }
: undefined),
...(staticFrontpage ? { staticFrontpage } : undefined),
...(label ? { label } : undefined),
...(closed ? { closed } : undefined),
};
run({ paths, octokit, repo, userOptions }).then(
() => console.log('Successfully built Microblog'),
(err) => {
console.log(err.message);
console.log(err.stack);
}
);