aboutsummaryrefslogtreecommitdiffstats
path: root/index.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2021-05-15 01:09:10 -0400
committerAdam Soltys <[email protected]>2021-05-15 01:09:10 -0400
commit3fc5dee44471633129ea01baeaf61afad695f4b7 (patch)
treebb16642b336b030fbfbdf32a9dfc013e62b6ccd1 /index.js
parent9a56065bbb93a3c7c6dd655b37a2ac825d175f14 (diff)
downloadcoinos-server-3fc5dee44471633129ea01baeaf61afad695f4b7.tar.gz
coinos-server-3fc5dee44471633129ea01baeaf61afad695f4b7.zip
build notifications
Diffstat (limited to 'index.js')
-rw-r--r--index.js34
1 files changed, 31 insertions, 3 deletions
diff --git a/index.js b/index.js
index 871e7530..d7dca11a 100644
--- a/index.js
+++ b/index.js
@@ -109,13 +109,41 @@ function verifyPostData(req, res, next) {
return next();
}
-app.post("/build", verifyPostData, (req, res) => {
+app.post("/build", (req, res) => {
+ const mailgun = require("mailgun-js")(config.mailgun);
+ let data = {
+ subject: "Build started",
+ text: `Build started at ${new Date()}`,
+ };
+
+ mailgun.messages().send(data);
+ l.info("Build starting");
fs.writeFileSync("build.json", req.body.payload);
const { exec } = require("child_process");
exec("bash build.sh", (error, stdout, stderr) => {
- if (error !== null) {
- console.log(`exec error: ${error}`);
+ if (error) {
+ data = {
+ subject: "Build error",
+ text: `Build failed at ${new Date()}`,
+ };
+
+ mailgun.messages().send(data);
+ l.warn("Build failed");
+ } else {
+ data = {
+ subject: "Build finished",
+ text: `Build finished at ${new Date()}`,
+ };
+
+ mailgun.messages().send(data);
+ l.info("Build finished");
}
});
});