Skip to content

Commit

Permalink
ci: reverting back to process manager deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
Kemzzy-Dev committed Aug 14, 2024
1 parent 2ae7e97 commit 5d059fa
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 134 deletions.
File renamed without changes.
48 changes: 0 additions & 48 deletions .github/workflows/dev-deployment.yaml

This file was deleted.

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

on:
workflow_dispatch:
push:
branches:
- main

jobs:
deploy-prod:
runs-on: bingo-server
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
47 changes: 0 additions & 47 deletions .github/workflows/production-deployment.yaml

This file was deleted.

36 changes: 5 additions & 31 deletions .github/workflows/staging-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,8 @@ on:
- staging

jobs:
build-and-push:
if: github.event.repository.fork == false
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 }}
deploy-staging:
runs-on: bingo-server
steps:
- name: Deploy on server
uses: appleboy/ssh-action@master
Expand All @@ -44,5 +17,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
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"
}
]
}
}
4 changes: 2 additions & 2 deletions staging-ecosystem-config.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"apps": [
{
"name": "team-alpha-staging",
"name": "nestjs2-staging",
"script": "npm run start:prod",
"log_file": "~/.pm2/logs/team-alpha-staging-out.log",
"combine_logs": true,
"log_date_format": "YYYY-MM-DD HH:mm:ss Z"
}
]
}
}

0 comments on commit 5d059fa

Please sign in to comment.