Skip to content

Commit

Permalink
final commit ig
Browse files Browse the repository at this point in the history
  • Loading branch information
dhanush-2313 committed Sep 22, 2024
1 parent 56a7bc8 commit 107fe19
Showing 1 changed file with 57 additions and 57 deletions.
114 changes: 57 additions & 57 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,68 +1,68 @@
name: Build and Push Docker Images
# name: Build and Push Docker Images

on:
push:
branches:
- main
# on:
# push:
# branches:
# - main

jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Check Out Repo
uses: actions/checkout@v2
# jobs:
# build-and-push:
# runs-on: ubuntu-latest
# steps:
# - name: Check Out Repo
# uses: actions/checkout@v2

- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# - name: Log in to Docker Hub
# uses: docker/login-action@v1
# with:
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and Push DB Handler Image
uses: docker/build-push-action@v2
with:
context: .
file: ./docker/Dockerfile.db
push: true
tags: dhanush2313/cicd:db-latest
# - name: Build and Push DB Handler Image
# uses: docker/build-push-action@v2
# with:
# context: .
# file: ./docker/Dockerfile.db
# push: true
# tags: dhanush2313/cicd:db-latest

- name: Build and Push User App Image
uses: docker/build-push-action@v2
with:
context: .
file: ./docker/Dockerfile.userapp
push: true
tags: dhanush2313/cicd:user-app-latest
# - name: Build and Push User App Image
# uses: docker/build-push-action@v2
# with:
# context: .
# file: ./docker/Dockerfile.userapp
# push: true
# tags: dhanush2313/cicd:user-app-latest

- name: Build and Push Webhook Handler Image
uses: docker/build-push-action@v2
with:
context: .
file: ./docker/Dockerfile.webhook
push: true
tags: dhanush2313/cicd:webhook-handler-latest
# - name: Build and Push Webhook Handler Image
# uses: docker/build-push-action@v2
# with:
# context: .
# file: ./docker/Dockerfile.webhook
# push: true
# tags: dhanush2313/cicd:webhook-handler-latest

- name: Deploy to EC2
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
script: |
sudo docker network create my_network || true
# - name: Deploy to EC2
# uses: appleboy/ssh-action@master
# with:
# host: ${{ secrets.SSH_HOST }}
# username: ${{ secrets.SSH_USERNAME }}
# key: ${{ secrets.SSH_KEY }}
# script: |
# sudo docker network create my_network || true

sudo docker pull dhanush2313/cicd:db-latest
sudo docker pull dhanush2313/cicd:user-app-latest
sudo docker pull dhanush2313/cicd:webhook-handler-latest
# sudo docker pull dhanush2313/cicd:db-latest
# sudo docker pull dhanush2313/cicd:user-app-latest
# sudo docker pull dhanush2313/cicd:webhook-handler-latest

sudo docker stop db || true
sudo docker rm db || true
sudo docker run -d --name db --network my_network -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=bruh123 -e POSTGRES_DB=postgres -p 5432:5432 dhanush2313/cicd:db-latest
# sudo docker stop db || true
# sudo docker rm db || true
# sudo docker run -d --name db --network my_network -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=bruh123 -e POSTGRES_DB=postgres -p 5432:5432 dhanush2313/cicd:db-latest

sudo docker stop user-app || true
sudo docker rm user-app || true
sudo docker run -d --name user-app --network my_network -e DATABASE_URL=postgresql://postgres:bruh123@db:5432/postgres -e WEBHOOK_URL=http://webhook-handler:3003 -p 3001:3001 dhanush2313/cicd:user-app-latest
# sudo docker stop user-app || true
# sudo docker rm user-app || true
# sudo docker run -d --name user-app --network my_network -e DATABASE_URL=postgresql://postgres:bruh123@db:5432/postgres -e WEBHOOK_URL=http://webhook-handler:3003 -p 3001:3001 dhanush2313/cicd:user-app-latest

sudo docker stop webhook-handler || true
sudo docker rm webhook-handler || true
sudo docker run -d --name webhook-handler --network my_network -e DATABASE_URL=postgresql://postgres:bruh123@db:5432/postgres -e PORT=3003 -p 3003:3003 dhanush2313/cicd:webhook-handler-latest
# sudo docker stop webhook-handler || true
# sudo docker rm webhook-handler || true
# sudo docker run -d --name webhook-handler --network my_network -e DATABASE_URL=postgresql://postgres:bruh123@db:5432/postgres -e PORT=3003 -p 3003:3003 dhanush2313/cicd:webhook-handler-latest

0 comments on commit 107fe19

Please sign in to comment.