-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
28 lines (24 loc) · 858 Bytes
/
index.js
File metadata and controls
28 lines (24 loc) · 858 Bytes
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
const { exec } = require("child_process");
const express = require("express");
const app = express();
app.use(express.json());
app.post("/backend", (req, res) => {
const { ref } = req.body;
if (ref !== "refs/heads/main") return res.sendStatus(400);
exec(
`cd /root/webapp && git stash && git pull && npm i && npm run build && pm2 restart Tianzu`
);
res.sendStatus(200);
});
app.post("/frontend", (req, res) => {
const { ref } = req.body;
if (ref !== "refs/heads/main") return res.sendStatus(400);
exec(
`cd /root/webapp-fe && git stash && git pull && npm i --legacy-peer-deps > /var/log/frontend-install.log && npm run build > /var/log/frontend-build.log && pm2 restart Tianzu`
);
res.sendStatus(200);
});
const port = 5074;
app.listen(port, () => {
console.log(`Listening on port ${port}`);
});