|
|
|
@ -14,7 +14,7 @@ const base64 = Buffer.from( |
|
|
|
|
|
|
|
|
|
app.use(Express.static(__dirname + "/out")); |
|
|
|
|
|
|
|
|
|
app.post("/", async (req, res) => { |
|
|
|
|
app.post("/", (req, res) => { |
|
|
|
|
const header = req.header("authorization"); |
|
|
|
|
|
|
|
|
|
if (header == null) { |
|
|
|
@ -39,23 +39,25 @@ app.post("/", async (req, res) => { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
res.send("Updating website ..."); |
|
|
|
|
|
|
|
|
|
await sleep(15); |
|
|
|
|
updateWebsite(); |
|
|
|
|
|
|
|
|
|
res.send("Updating website ..."); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
app.listen(PORT, () => { |
|
|
|
|
console.log(`👀 http://localhost:${PORT}`); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
function updateWebsite() { |
|
|
|
|
async function updateWebsite() { |
|
|
|
|
const branch = "main"; |
|
|
|
|
const job = "staging"; |
|
|
|
|
const url = `https://git.uwaterloo.ca/csc/website/-/jobs/artifacts/${branch}/download?job=${job}`; |
|
|
|
|
|
|
|
|
|
const zipPath = `zips/${branch}.zip`; |
|
|
|
|
|
|
|
|
|
// Wait for pipeline to succeed and artifacts to be available
|
|
|
|
|
await sleep(120); |
|
|
|
|
|
|
|
|
|
execSync(`wget -O ${zipPath} '${url}'`); |
|
|
|
|
execSync(`yes All | unzip ${zipPath}`); |
|
|
|
|
} |
|
|
|
|