Skip to content

Commit

Permalink
Merge pull request #93 from BinaryStudioAcademy/task/OV-86-add-deploy…
Browse files Browse the repository at this point in the history
…ment

OV-86: Add deployment
  • Loading branch information
anton-otroshchenko authored Sep 2, 2024
2 parents b7a4ffe + dfc07f9 commit 27ad07f
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 5 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Continuous Delivery

env:
AWS_REGION: eu-north-1
EBS_APP_NAME: bsa-2024-outreachvids
ENVIRONMENT: next

on:
push:
branches:
- next
workflow_dispatch:

jobs:
cd:
runs-on: ubuntu-latest

steps:
- name: Checkout Source Code
uses: actions/checkout@v4

- name: Install NodeJS
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc

- name: Zipping Deployment Package
run: |
zip -r build.zip . -x .github
- name: Deploy to EB
uses: einaregilsson/beanstalk-deploy@v21
with:
use_existing_version_if_available: true
aws_access_key: ${{ secrets.AWS_ACCESS_KEY }}
aws_secret_key: ${{ secrets.AWS_SECRET_KEY }}
region: ${{ env.AWS_REGION }}
application_name: ${{ env.EBS_APP_NAME }}
environment_name: ${{ env.ENVIRONMENT }}
version_label: ${{ github.sha }}
deployment_package: ./build.zip
wait_for_environment_recovery: 300
10 changes: 9 additions & 1 deletion backend/src/common/database/base-database.package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,17 @@ class BaseDatabase implements Database {
}

private get initialConfig(): TKnex.Config {
const sslConfig =
this.appConfig.ENV.APP.ENVIRONMENT === AppEnvironment.DEVELOPMENT
? null
: { ssl: { rejectUnauthorized: false } };

return {
client: this.appConfig.ENV.DB.DIALECT,
connection: this.appConfig.ENV.DB.CONNECTION_STRING,
connection: {
connectionString: this.appConfig.ENV.DB.CONNECTION_STRING,
...(!!sslConfig && sslConfig),
},
pool: {
min: this.appConfig.ENV.DB.POOL_MIN,
max: this.appConfig.ENV.DB.POOL_MAX,
Expand Down
3 changes: 2 additions & 1 deletion backend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"baseUrl": ".",
"paths": {
"~/*": ["./src/*"]
}
},
"outDir": "build"
}
}
1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
"frontend"
],
"scripts": {
"postinstall": "npm run build:shared",
"build:shared": "npm run build -w shared",
"build:frontend": "npm run build -w frontend",
"build:backend": "npm run build -w backend",
"build": "npm run build:shared && npm run build:backend && npm run build:frontend && sh ./prepare-build.sh",
"lint:editor": "editorconfig-checker",
"lint:fs": "ls-lint",
"lint:type": "npm run lint:type --workspaces --if-present",
Expand All @@ -25,7 +25,10 @@
"lint:format": "prettier --check \"**/*.{ts,tsx,json,md,scss,html,yml}\"",
"lint": "npm run lint:editor && npm run lint:fs && npm run lint:format && npm run lint:type && npm run lint:js && npm run lint:css",
"lint:fix": "npm run lint:fix -w frontend && npm run lint:fix -w backend",
"format": "prettier --write \"**/*.{ts,tsx,json,md,css,html,yml}\""
"format": "prettier --write \"**/*.{ts,tsx,json,md,css,html,yml}\"",
"migrate": "npm run migrate:dev -w backend",
"prestart": "npm install --include=dev && npm run build && npm run migrate",
"start": "cd ./build/backend && npm run start"
},
"devDependencies": {
"@commitlint/cli": "19.4.0",
Expand Down
5 changes: 5 additions & 0 deletions prepare-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
mkdir -p ./build/backend; mv ./backend/build/* ./build/backend
mkdir ./build/backend/public; mv ./frontend/build/* ./build/backend/public
cp ./backend/package.json ./build/backend
cp package.json package-lock.json ./build

0 comments on commit 27ad07f

Please sign in to comment.