-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
53 lines (46 loc) · 1.06 KB
/
app.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
"use strict";
const Hexo = require("hexo");
exports.handler = (event,context,callback) => {
/* Load the Node Modules for Git */
var Git = require("nodegit");
let cloneOpts = {
checkoutBranch: "source",
fetchOpts: {
callbacks: {
credentials: (url,username) => {
return Git.Cred.sshKeyNew(
username,
`keys/${process.env["GIT_SSH_PUBLIC_KEY"]}`,
`keys/${process.env["GIT_SSH_PRIVATE_KEY"]}`,
""
);
}
}
}
};
Git.Clone(process.env["GIT_REPO_URL"], "tmp/src", cloneOpts)
.then( (repo) => {
console.info(`Checking out ${process.env["GIT_REPO_URL"]}`);
var hexo = new Hexo("tmp/src", {});
hexo.init().then( () => {
console.info("Running Hexo Generate");
hexo.call("generate",{})
.then( () => {
return hexo.exit();
})
.catch( () => {
return hexo.exit();
});
});
})
.catch( (repo) => {
//console.info("Error",repo);
callback(repo);
});
};
/*
exports.handler({},{},function(err,data){
if(err) { console.error(new Error(err)); return; }
console.info(data);
});
*/