Skip to content

Commit

Permalink
Merge pull request #1158 from hngprojects/dev
Browse files Browse the repository at this point in the history
Merge branch 'dev' into staging
  • Loading branch information
Homoakin619 authored Aug 24, 2024
2 parents c05ee85 + 3ca9270 commit d794188
Show file tree
Hide file tree
Showing 83 changed files with 2,084 additions and 1,136 deletions.
2 changes: 1 addition & 1 deletion .env.local
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ PORT=3000
DB_USERNAME=username
DB_PASSWORD=password
DB_TYPE=postgres
DB_DATABASE=database
DB_NAME=database
DB_HOST=localhost
DB_PORT=5432
DB_ENTITIES=dist/src/modules/**/entities/**/*.entity{.ts,.js}
Expand Down
27 changes: 27 additions & 0 deletions .github/Unused/pr-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# name: PR Deploy
# on:
# pull_request_target:
# branches:
# - dev

# jobs:
# deploy-pr-for-testing:
# environment:
# name: preview
# url: ${{ steps.deploy.outputs.preview-url }}
# runs-on: ubuntu-latest
# steps:
# - name: Checkout to branch
# uses: actions/checkout@v4
# - id: deploy
# name: Pull Request Deploy
# uses: hngprojects/pr-deploy@dev
# with:
# server_host: ${{ secrets.HOST }}
# server_username: ${{ secrets.USERNAME }}
# server_password: ${{ secrets.PASSWORD }}
# comment: false
# context: .
# dockerfile: Dockerfile
# exposed_port: 5000
# github_token: ${{ secrets.GITHUB_TOKEN }}
48 changes: 0 additions & 48 deletions .github/workflows/dev-deployment.yaml

This file was deleted.

21 changes: 21 additions & 0 deletions .github/workflows/main-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Production Deployment

on:
push:
branches:
- main

jobs:
deploy-prod:
runs-on: ubuntu-latest
steps:
- name: Deploy on server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
script: |
cd main
chmod +x deployment.sh
./deployment.sh main
27 changes: 0 additions & 27 deletions .github/workflows/pr-deploy.yaml

This file was deleted.

47 changes: 0 additions & 47 deletions .github/workflows/production-deployment.yaml

This file was deleted.

22 changes: 22 additions & 0 deletions .github/workflows/scheduled-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Scheduled Test

on:
schedule:
- cron: '*/15 * * * *'

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Run test script
env:
POSTMAN_API_KEY: ${{ secrets.POSTMAN_API_KEY }}
API_URL: ${{ secrets.API_URL }}
run: |
cd qa
chmod +x test.sh
./test.sh
35 changes: 4 additions & 31 deletions .github/workflows/staging-deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,41 +1,13 @@
name: Staging Deployment

on:
workflow_dispatch:
push:
branches:
- staging

jobs:
build-and-push:
if: github.event.repository.fork == false
deploy-staging:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Build Docker image
run: docker build -t nestjs_staging:green .

- name: Save and compress Docker image
run: |
docker save nestjs_staging:green | gzip > nestjs_staging.tar.gz
- name: Copy image to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
source: 'nestjs_staging.tar.gz'
target: '/tmp'

deploy:
needs: build-and-push
runs-on: ubuntu-latest
environment:
name: 'staging'
url: ${{ vars.URL }}
steps:
- name: Deploy on server
uses: appleboy/ssh-action@master
Expand All @@ -44,5 +16,6 @@ jobs:
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
script: |
cd ~/hng_boilerplate_nestjs
./deploy.sh staging
cd staging
chmod +x deployment.sh
./deployment.sh staging
13 changes: 9 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@
"statusBar.background": "#1a1f15",
"statusBarItem.hoverBackground": "#333d2a",
"statusBar.foreground": "#e7e7e7",
"panel.border": "#333d2a",
"sideBar.border": "#333d2a",
"editorGroup.border": "#333d2a"
"commandCenter.border": "#e7e7e799",
"sash.hoverBorder": "#333d2a",
"statusBarItem.remoteBackground": "#1a1f15",
"statusBarItem.remoteForeground": "#e7e7e7",
"titleBar.activeBackground": "#1a1f15",
"titleBar.activeForeground": "#e7e7e7",
"titleBar.inactiveBackground": "#1a1f1599",
"titleBar.inactiveForeground": "#e7e7e799"
},
"peacock.color": "#1a1f15",
"eslint.validate": [
Expand All @@ -28,6 +33,6 @@
"source.fixAll": "explicit"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
}
}
File renamed without changes.
8 changes: 4 additions & 4 deletions compose.yaml → compose/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ services:
redis:
condition: service_healthy
healthcheck:
test: "wget -qO- http://app:${PORT}"
test: 'wget -qO- http://app:${PORT}'
interval: 10s
timeout: 10s
retries: 3
Expand All @@ -28,7 +28,7 @@ services:
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: "pg_isready -U postgres"
test: 'pg_isready -U postgres'
interval: 5s
timeout: 5s
retries: 3
Expand All @@ -41,7 +41,7 @@ services:
volumes:
- redis_data:/data
healthcheck:
test: "redis-cli ping | grep PONG"
test: 'redis-cli ping | grep PONG'
interval: 5s
timeout: 5s
retries: 3
Expand All @@ -55,7 +55,7 @@ services:
app:
condition: service_healthy
healthcheck:
test: "wget -qO- http://nginx:80"
test: 'wget -qO- http://nginx:80'
interval: 5s
timeout: 5s
retries: 3
Expand Down
File renamed without changes.
23 changes: 23 additions & 0 deletions deployment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

BRANCH=$1

# checkout
git checkout $BRANCH;

git pull origin $BRANCH;

# install dependencies
npm install --include=dev;

# run build
npm run build;


git stash

# run migration
npm run migration:run;

# run start
pm2 restart $BRANCH-ecosystem-config.json || pm2 start $BRANCH-ecosystem-config.json;
4 changes: 2 additions & 2 deletions main-ecosystem-config.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"apps": [
{
"name": "team-alpha-prod",
"name": "nestjs-prod",
"script": "npm run start:prod",
"log_file": "~/.pm2/logs/team-alpha-prod-out.log",
"combine_logs": true,
"log_date_format": "YYYY-MM-DD HH:mm:ss Z"
}
]
}
}
Loading

0 comments on commit d794188

Please sign in to comment.