diff --git a/csccp.js b/csccp.js index 95e014c..28b6285 100644 --- a/csccp.js +++ b/csccp.js @@ -3,17 +3,22 @@ const express = require('express') const app = express() const port = 2344 -const name = "cscclassprofilestaging" -const image = "registry.cloud.csclub.uwaterloo.ca/snedadah/csc-class-profile-staging" app.get('/cscclassprofilestaging', async (req, res) => { - await call(`kubectl delete deployment ${name}`); + const buildId = req.query.ref; + const name = `${buildId}-cscclassprofilestaging` + const publicUrl = `${name}-snedadah.k8s.csclub.cloud` + const image = `registry.cloud.csclub.uwaterloo.ca/snedadah/csc-class-profile-staging:${buildId}` + console.log("branch is " + req.query.ref, req.query); + + await call(`kubectl delete deployment ${name}`); await call(`kubectl create deployment ${name} --image ${image} --port=80`); await call(`kubectl expose deployment ${name}`); - await call(`kubectl create ingress ${name} --rule='${name}-snedadah.k8s.csclub.cloud/*=${name}:80'`); + await call(`kubectl create ingress ${name} --rule='${publicUrl}/*=${name}:80'`); + console.log("Deploying on " + publicUrl); - res.send('Finished redeploy!') + res.send(publicUrl); }) async function call(cmd){ @@ -26,5 +31,5 @@ async function call(cmd){ } } app.listen(port, () => { - console.log(`Example app listening on port ${port}`) + console.log(`Listening on port ${port}`) })