From 9feb21ba61ff0956de0920c28fda754f7f07a443 Mon Sep 17 00:00:00 2001 From: Robinson Uchechukwu Date: Fri, 9 Aug 2024 18:30:16 +0100 Subject: [PATCH 01/10] Update .env path in docker-compose.yml --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index b3b36c4f..89f740c9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ services: ports: - 2222:8000 env_file: - - /var/www/aihomework/dev/.env + - .env environment: NODE_ENV: development DB_HOST: backend_db @@ -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} From 5966e228c61095d4b362cbcf42fe897b6edddee9 Mon Sep 17 00:00:00 2001 From: Robinson Uchechukwu Date: Fri, 9 Aug 2024 18:30:52 +0100 Subject: [PATCH 02/10] Update .env path in docker-compose.staging.yml --- docker-compose.staging.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.staging.yml b/docker-compose.staging.yml index 1c49750c..8abf5b17 100644 --- a/docker-compose.staging.yml +++ b/docker-compose.staging.yml @@ -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 @@ -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} From f96e264f254fa66b8dd2a6fdb0c254d005f2dc39 Mon Sep 17 00:00:00 2001 From: Robinson Uchechukwu Date: Fri, 9 Aug 2024 18:31:26 +0100 Subject: [PATCH 03/10] Update .env path in docker-compose.production.yml --- docker-compose.production.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.production.yml b/docker-compose.production.yml index 82eb3069..39ba8c10 100644 --- a/docker-compose.production.yml +++ b/docker-compose.production.yml @@ -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 @@ -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} From 82179da2f23ead2b8b9942ea1fb2413e6b5d5dc5 Mon Sep 17 00:00:00 2001 From: Robinson Uchechukwu Date: Fri, 9 Aug 2024 18:39:00 +0100 Subject: [PATCH 04/10] Update dev.yml --- .github/workflows/dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index dc4f8744..291e3bb8 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -1,4 +1,4 @@ -name: Build, Test, and Deploy for Dev Branch +name: Deploy to Dev on: push: From 3c3abbf9bf44368182bf8de6705a45c02a5a4586 Mon Sep 17 00:00:00 2001 From: Robinson Uchechukwu Date: Fri, 9 Aug 2024 18:39:31 +0100 Subject: [PATCH 05/10] Update prod.yml --- .github/workflows/prod.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/prod.yml b/.github/workflows/prod.yml index 21f8983d..e275d488 100644 --- a/.github/workflows/prod.yml +++ b/.github/workflows/prod.yml @@ -1,9 +1,9 @@ -name: Deploy to staging Branch +name: Deploy to prod Branch on: push: branches: - - dev + - prod jobs: build-and-deploy: From df14e73a45807abdd28bc0f419b3005970980d54 Mon Sep 17 00:00:00 2001 From: Robinson Uchechukwu Date: Fri, 9 Aug 2024 18:48:01 +0100 Subject: [PATCH 06/10] Update staging.yml depends on CI --- .github/workflows/staging.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml index 5c6d315e..6a458a03 100644 --- a/.github/workflows/staging.yml +++ b/.github/workflows/staging.yml @@ -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 From 41f37aeafb3da2c251e6358507b7ff21a835f6c3 Mon Sep 17 00:00:00 2001 From: Robinson Uchechukwu Date: Fri, 9 Aug 2024 18:49:30 +0100 Subject: [PATCH 07/10] Update CI.yml run on push to all branches and on pull requests --- .github/workflows/CI.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 20a83ed3..dc06e527 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -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: @@ -25,5 +27,6 @@ jobs: run: yarn test env: CI: true - - name: buld the dist + + - name: Build the dist run: yarn build From ffce86a23cd0f192e564f15d2f9ab8a38793b5d2 Mon Sep 17 00:00:00 2001 From: Robinson Uchechukwu Date: Fri, 9 Aug 2024 18:50:11 +0100 Subject: [PATCH 08/10] Update dev.yml depends on ci --- .github/workflows/dev.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 291e3bb8..1a367ce4 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -1,9 +1,11 @@ name: Deploy to Dev on: - push: - branches: - - dev + workflow_run: + workflows: [CI] + types: + - completed + branches: [dev] jobs: build-and-deploy: From de40e9acc8a6d920d8076d63525c593289bf4c1d Mon Sep 17 00:00:00 2001 From: Robinson Uchechukwu Date: Fri, 9 Aug 2024 18:51:40 +0100 Subject: [PATCH 09/10] Update prod.yml depend on ci --- .github/workflows/prod.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/prod.yml b/.github/workflows/prod.yml index e275d488..0f580ff5 100644 --- a/.github/workflows/prod.yml +++ b/.github/workflows/prod.yml @@ -1,9 +1,11 @@ name: Deploy to prod Branch on: - push: - branches: - - prod + workflow_run: + workflows: [CI] + types: + - completed + branches: [main] jobs: build-and-deploy: @@ -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 }} From 076de18eaa49119e979076c9c40157ab1842b58c Mon Sep 17 00:00:00 2001 From: Robinson Uchechukwu Date: Fri, 9 Aug 2024 18:52:53 +0100 Subject: [PATCH 10/10] Update staging.yml pull staging branch --- .github/workflows/staging.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml index 6a458a03..729c31ee 100644 --- a/.github/workflows/staging.yml +++ b/.github/workflows/staging.yml @@ -44,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