diff --git a/.github/workflows/backend.yml b/.github/workflows/backend.yml new file mode 100644 index 00000000..e1e42c07 --- /dev/null +++ b/.github/workflows/backend.yml @@ -0,0 +1,41 @@ +# This is a basic workflow to help deploy the backend code to Azure server +# it triggers on push and pull request events to the master branch +# it runs the jobs on the API/ directory and deploys using secret credentials +# Update the secret credentials with details from the Azure web server. + +name: "Pipeline for Azure webapp deployment" + +on: + push: + branches: + - master + pull_request: + types: [opened, synchronize, reopened, closed] + branches: + - master +jobs: + build_and_deploy: + name: Build test and Deploy Node App to Azure + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js + uses: actions/setup-node@v2 + with: + node-version: "14" + - name: npm install, build, and test + run: | + cd API/ + npm install + npm run build --if-present + npm run test --passWithNoTests + echo Successful + + - name: "Deploy to Azure" + uses: azure/webapps-deploy@v2 + with: + app-name: ${{ secrets.AZURE_WEBAPP_NAME }} + publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} + package: ${{ secrets.AZURE_WEBAPP_PACKAGE_PATH }} + if: github.ref == 'refs/heads/master' && job.status == 'success' diff --git a/API/package.json b/API/package.json index 060806a1..00254671 100644 --- a/API/package.json +++ b/API/package.json @@ -1,73 +1,69 @@ { - "name": "lockdown-api", - "version": "2.0", - "description": "", - "author": "Project Lockdown", - "private": true, - "scripts": { - "prebuild": "rimraf dist", - "build": "nest build", - "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", - "start": "nest start", - "start:dev": "nest start --watch", - "start:debug": "nest start --debug --watch", - "start:prod": "node dist/main", - "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", - "test": "jest", - "test:watch": "jest --watch", - "test:cov": "jest --coverage", - "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", - "test:e2e": "jest --config ./test/jest-e2e.json" - }, - "dependencies": { - "@nestjs/common": "^7.6.15", - "@nestjs/core": "^7.6.15", - "@nestjs/platform-express": "^7.6.15", - "@nestjs/swagger": "^4.8.1", - "dotenv": "^10.0.0", - "mongoose": "^5.12.14", - "reflect-metadata": "^0.1.13", - "rimraf": "^3.0.2", - "rxjs": "^6.6.6", - "swagger-ui-express": "^4.1.6" - }, - "devDependencies": { - "@nestjs/cli": "^7.6.0", - "@nestjs/schematics": "^7.3.0", - "@nestjs/testing": "^7.6.15", - "@types/express": "^4.17.11", - "@types/jest": "^26.0.22", - "@types/node": "^14.17.3", - "@types/supertest": "^2.0.10", - "@typescript-eslint/eslint-plugin": "^4.19.0", - "@typescript-eslint/parser": "^4.19.0", - "eslint": "^7.22.0", - "eslint-config-prettier": "^8.1.0", - "eslint-plugin-prettier": "^3.3.1", - "jest": "^26.6.3", - "prettier": "^2.2.1", - "supertest": "^6.1.3", - "ts-jest": "^26.5.4", - "ts-loader": "^8.0.18", - "ts-node": "^9.1.1", - "tsconfig-paths": "^3.9.0", - "typescript": "^4.2.3" - }, - "jest": { - "moduleFileExtensions": [ - "js", - "json", - "ts" - ], - "rootDir": "src/", - "testRegex": ".*\\.test\\.ts$", - "transform": { - "^.+\\.(t|j)s$": "ts-jest" + "name": "lockdown-api", + "version": "2.0.0", + "description": "", + "author": "Project Lockdown", + "private": true, + "scripts": { + "prebuild": "rimraf dist", + "build": "nest build", + "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", + "start": "nest start", + "start:dev": "nest start --watch", + "start:debug": "nest start --debug --watch", + "start:prod": "node dist/main", + "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", + "test": "jest", + "test:watch": "jest --watch", + "test:cov": "jest --coverage", + "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", + "test:e2e": "jest --config ./test/jest-e2e.json" }, - "collectCoverageFrom": [ - "**/*.(t|j)s" - ], - "coverageDirectory": "../coverage", - "testEnvironment": "node" - } + "dependencies": { + "@nestjs/common": "^7.6.15", + "@nestjs/core": "^7.6.15", + "@nestjs/platform-express": "^7.6.15", + "reflect-metadata": "^0.1.13", + "rimraf": "^3.0.2", + "rxjs": "^6.6.6" + }, + "devDependencies": { + "@nestjs/cli": "^7.6.0", + "@nestjs/schematics": "^7.3.0", + "@nestjs/testing": "^7.6.15", + "@types/express": "^4.17.11", + "@types/jest": "^26.0.22", + "@types/node": "^14.14.36", + "@types/supertest": "^2.0.10", + "@typescript-eslint/eslint-plugin": "^4.19.0", + "@typescript-eslint/parser": "^4.19.0", + "eslint": "^7.22.0", + "eslint-config-prettier": "^8.1.0", + "eslint-plugin-prettier": "^3.3.1", + "jest": "^26.6.3", + "prettier": "^2.2.1", + "supertest": "^6.1.3", + "ts-jest": "^26.5.4", + "ts-loader": "^8.0.18", + "ts-node": "^9.1.1", + "tsconfig-paths": "^3.9.0", + "typescript": "^4.2.3" + }, + "jest": { + "moduleFileExtensions": [ + "js", + "json", + "ts" + ], + "rootDir": "src/", + "testRegex": ".*\\.test\\.ts$", + "transform": { + "^.+\\.(t|j)s$": "ts-jest" + }, + "collectCoverageFrom": [ + "**/*.(t|j)s" + ], + "coverageDirectory": "../coverage", + "testEnvironment": "node" + } } diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index b95aa1c8..00000000 --- a/package-lock.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "requires": true, - "lockfileVersion": 1, - "dependencies": { - "@babel/runtime": { - "version": "7.12.13", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.12.13.tgz", - "integrity": "sha512-8+3UMPBrjFa/6TtKi/7sehPKqfAm4g6K+YQjyyFOLUTxzOngcRZTlAVY8sc2CORJYqdHQY8gRPHmn+qo15rCBw==", - "requires": { - "regenerator-runtime": "^0.13.4" - } - }, - "html-parse-stringify2": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/html-parse-stringify2/-/html-parse-stringify2-2.0.1.tgz", - "integrity": "sha1-3FZwtyksoVi3vJFsmmc1rIhyg0o=", - "requires": { - "void-elements": "^2.0.1" - } - }, - "i18next-browser-languagedetector": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/i18next-browser-languagedetector/-/i18next-browser-languagedetector-6.0.1.tgz", - "integrity": "sha512-3H+OsNQn3FciomUU0d4zPFHsvJv4X66lBelXk9hnIDYDsveIgT7dWZ3/VvcSlpKk9lvCK770blRZ/CwHMXZqWw==", - "requires": { - "@babel/runtime": "^7.5.5" - } - }, - "i18next-http-backend": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/i18next-http-backend/-/i18next-http-backend-1.1.0.tgz", - "integrity": "sha512-utp3MyUQpIUD5Jxkf5xz0GWYWDSte7uuf1F4qaLtVtIqlcFcyYQ2l22el1JPK3rAL44+sjhB7+ct0Qr2WpbxNA==", - "requires": { - "node-fetch": "2.6.1" - } - }, - "node-fetch": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", - "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==" - }, - "react-i18next": { - "version": "11.8.6", - "resolved": "https://registry.npmjs.org/react-i18next/-/react-i18next-11.8.6.tgz", - "integrity": "sha512-Nr4Fq7BvzDLJQmaDyJRkPPINgMW1Y1qeT4STBoY/ePGmYlCZGShTYqqyBm0ly6M8dV1X0twt7M5dfmDzfi9yGQ==", - "requires": { - "@babel/runtime": "^7.3.1", - "html-parse-stringify2": "2.0.1" - } - }, - "regenerator-runtime": { - "version": "0.13.7", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz", - "integrity": "sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew==" - }, - "void-elements": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/void-elements/-/void-elements-2.0.1.tgz", - "integrity": "sha1-wGavtYK7HLQSjWDqkjkulNXp2+w=" - } - } -}