diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index b66f4bf..754de2e 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -39,15 +39,7 @@ jobs: - name: Build and push Docker images - Server uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc with: - context: ./server/ - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - - - name: Build and push Docker images - Ui - uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc - with: - context: ./ui/ + context: . push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/.github/workflows/node.js.yml b/.github/workflows/pipeline.yml similarity index 91% rename from .github/workflows/node.js.yml rename to .github/workflows/pipeline.yml index 3cb6b81..222a55f 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/pipeline.yml @@ -191,3 +191,19 @@ jobs: with: branch: gh-pages folder: dist + + deploy2heroku: + runs-on: ubuntu-latest + needs: [test-server,test-ui-unit,test-ui-integration] + + if: >- + github.event_name == 'pull_request' + steps: + - uses: actions/checkout@v2 + + - name: Deploy to Heroku + uses: AkhileshNS/heroku-deploy@v3.12.12 + with: + heroku_api_key: ${{secrets.HEROKU_API_KEY}} + heroku_app_name: "cssd-highway" + heroku_email: "b8043407@my.shu.ac.uk" \ No newline at end of file diff --git a/server/app.js b/server/app.js index 6adc989..0287aeb 100644 --- a/server/app.js +++ b/server/app.js @@ -4,8 +4,8 @@ const bodyParser = require("body-parser"); const cors = require("cors"); const cookieSession = require("cookie-session"); const cookieParser = require("cookie-parser"); -const swaggerUi = require('swagger-ui-express'), - swaggerDocument = require('./swagger.json') +const swaggerUi = require("swagger-ui-express"), + swaggerDocument = require("./swagger.json"); require("./database"); require("dotenv").config(); @@ -21,7 +21,12 @@ app.use( }) ); -app.use(cors({ origin: "http://localhost:8080", credentials: true })); +app.use( + cors({ + origin: ["http://localhost:8080", "https://jarrodback.github.io"], + credentials: true, + }) +); /** * Router setup @@ -29,8 +34,9 @@ app.use(cors({ origin: "http://localhost:8080", credentials: true })); const authRouter = require("./routes/auth.routes"); const billRouter = require("./routes/bill.routes"); const userRouter = require("./routes/user.routes"); -app.get('/api-docs/swagger.json', (req, res) => res.json(swaggerDocument)); -app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument)); + +app.get("/api-docs/swagger.json", (req, res) => res.json(swaggerDocument)); +app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerDocument)); /** * View Engine setup diff --git a/server/config/db.config.js b/server/config/db.config.js index 20128fb..8052b39 100644 --- a/server/config/db.config.js +++ b/server/config/db.config.js @@ -6,6 +6,6 @@ module.exports = { url: "mongodb://localhost:27017/highwaytrackerdb_testing", }, production: { - url: "mongodb://mongo:27017/highwaytrackerdb", + url: process.env.MONGODB_URI, }, }; diff --git a/ui/src/api/api.js b/ui/src/api/api.js index 6729754..0280513 100644 --- a/ui/src/api/api.js +++ b/ui/src/api/api.js @@ -2,8 +2,14 @@ const api = class Api { constructor() { - this.baseUrl = "http://localhost:3000"; - this.authUrl = "http://localhost:3000/auth"; + this.baseUrl = + process.env.NODE_ENV === "production" + ? "https://cssd-highway.herokuapp.com" + : "http://localhost:3000"; + this.authUrl = + process.env.NODE_ENV === "production" + ? "https://cssd-highway.herokuapp.com/auth" + : "http://localhost:3000/auth"; } async getAllBills(queryString) {