Skip to content

Commit

Permalink
Merge pull request #568 from hngprojects/fix-workflows
Browse files Browse the repository at this point in the history
Fix workflows
  • Loading branch information
Lanky-23 authored Aug 10, 2024
2 parents ab4a4ff + 076de18 commit b09641c
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 26 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
name: CI

on:
push:
branches: [dev, staging, main]
pull_request:
branches:
- dev
types: [opened, synchronize, reopened]
branches: [dev, staging, main]

jobs:
test:
Expand All @@ -25,5 +27,6 @@ jobs:
run: yarn test
env:
CI: true
- name: buld the dist

- name: Build the dist
run: yarn build
10 changes: 6 additions & 4 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
name: Build, Test, and Deploy for Dev Branch
name: Deploy to Dev

on:
push:
branches:
- dev
workflow_run:
workflows: [CI]
types:
- completed
branches: [dev]

jobs:
build-and-deploy:
Expand Down
15 changes: 8 additions & 7 deletions .github/workflows/prod.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
name: Deploy to staging Branch
name: Deploy to prod Branch

on:
push:
branches:
- dev
workflow_run:
workflows: [CI]
types:
- completed
branches: [main]

jobs:
build-and-deploy:
Expand Down Expand Up @@ -42,13 +44,12 @@ jobs:
- name: Deploy and start on remote server
run: |
sshpass -p ${{ secrets.PASSWORD }} ssh -o StrictHostKeyChecking=no ${{ secrets.USERNAME }}@${{ secrets.HOST }} "
cd /var/www/aihomework/dev
cd /var/www/aihomework/prod
git stash
git pull origin dev
git pull origin main
docker load -i /tmp/docker-images.tar.gz
docker compose -f docker-compose.production.yml down
docker compose -f docker-compose.production.yml up -d
rm /tmp/docker-images.tar.gz
"
env:
SSH_HOST: ${{ secrets.HOST }}
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
name: Deploy to staging Branch

on:
push:
branches:
- dev

workflow_run:
workflows: [CI]
types:
- completed
branches: [staging]

jobs:
build-and-deploy:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -42,9 +44,9 @@ jobs:
- name: Deploy and start on remote server
run: |
sshpass -p ${{ secrets.PASSWORD }} ssh -o StrictHostKeyChecking=no ${{ secrets.USERNAME }}@${{ secrets.HOST }} "
cd /var/www/aihomework/dev
cd /var/www/aihomework/staging
git stash
git pull origin dev
git pull origin staging
docker load -i /tmp/docker-images.tar.gz
docker compose -f docker-compose.staging.yml down
docker compose -f docker-compose.staging.yml up -d
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
ports:
- 4444:8000
env_file:
- /var/www/aihomework/prod/.env
- .env
environment:
NODE_ENV: production
DB_HOST: backend_db_prod
Expand All @@ -24,7 +24,7 @@ services:
container_name: backend_db_prod
restart: unless-stopped
env_file:
- /var/www/aihomework/prod/.env
- .env
environment:
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_PASSWORD}
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
ports:
- 3333:8000
env_file:
- /var/www/aihomework/staging/.env
- .env
environment:
NODE_ENV: staging
DB_HOST: backend_db_staging
Expand All @@ -24,7 +24,7 @@ services:
container_name: backend_db_staging
restart: unless-stopped
env_file:
- /var/www/aihomework/staging/.env
- .env
environment:
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_PASSWORD}
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
ports:
- 2222:8000
env_file:
- /var/www/aihomework/dev/.env
- .env
environment:
NODE_ENV: development
DB_HOST: backend_db
Expand All @@ -24,7 +24,7 @@ services:
container_name: backend_db
restart: unless-stopped
env_file:
- /var/www/aihomework/dev/.env
- .env
environment:
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_PASSWORD}
Expand Down

0 comments on commit b09641c

Please sign in to comment.