diff options
| author | Adam Soltys <[email protected]> | 2021-05-15 01:09:10 -0400 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2021-05-15 01:09:10 -0400 |
| commit | 3fc5dee44471633129ea01baeaf61afad695f4b7 (patch) | |
| tree | bb16642b336b030fbfbdf32a9dfc013e62b6ccd1 /index.js | |
| parent | 9a56065bbb93a3c7c6dd655b37a2ac825d175f14 (diff) | |
| download | coinos-server-3fc5dee44471633129ea01baeaf61afad695f4b7.tar.gz coinos-server-3fc5dee44471633129ea01baeaf61afad695f4b7.zip | |
build notifications
Diffstat (limited to 'index.js')
| -rw-r--r-- | index.js | 34 |
1 files changed, 31 insertions, 3 deletions
@@ -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()}`, + from: "[email protected]", + to: "[email protected]" + }; + + 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()}`, + from: "[email protected]", + to: "[email protected]" + }; + + mailgun.messages().send(data); + l.warn("Build failed"); + } else { + data = { + subject: "Build finished", + text: `Build finished at ${new Date()}`, + from: "[email protected]", + to: "[email protected]" + }; + + mailgun.messages().send(data); + l.info("Build finished"); } }); }); |
