Skip to content

Commit

Permalink
file updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Akshat-Kumar-work committed Jul 25, 2024
1 parent 5d0aeb2 commit 576426d
Showing 1 changed file with 20 additions and 24 deletions.
44 changes: 20 additions & 24 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#CD PIPELINE FILE

name: Build and Deploy to Docker Hub

on:
Expand All @@ -9,38 +7,36 @@ on:

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

- name: Log in to Docker Hub #log into docker hub repo
- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }} #with username coming from github secret
password: ${{ secrets.DOCKER_PASSWORD }} #with password coming from github secret
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and Push Docker image #build image and pushed the image to docker hub repo
- name: Build and Push Docker image
uses: docker/build-push-action@v2
with:
context: .
file: ./docker/Dockerfile.userApp #docker file path
file: ./docker/Dockerfile.userApp
push: true
tags: akshatwork6/user-app-image:latest # dockerhub username/ repo name where we have to push the image
tags: akshatwork6/user-app-image:latest

- name: Verify Pushed Image # pull the created image from docker hub repo
run: docker pull akshatwork6/user-app-image:latest #command to pull the image
- name: Verify Pushed Image
run: docker pull akshatwork6/user-app-image: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 pull akshatwork6/user-app-image:latest
sudo docker stop web-app || true
sudo docker rm web-app || true
sudo docker run -e JWT_SECRET=${{ secrets.JWT_SECRET }} -e DATABASE_URL=${{ secrets.DB_URL }} -e GOOGLE_SECRET=${{ secrets.GOOGLE_SECRET }} -e GOOGLE_ID=${{ secrets.GOOGLE_ID }} -d --name web-app --restart unless-stopped -p 3005:3000 akshatwork6/user-app-image:latest
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
script: |
sudo docker pull akshatwork6/user-app-image:latest
sudo docker stop web-app || true
sudo docker rm web-app || true
sudo docker run -e JWT_SECRET=${{ secrets.JWT_SECRET }} -e DATABASE_URL=${{ secrets.DB_URL }} -e GOOGLE_SECRET=${{ secrets.GOOGLE_SECRET }} -e GOOGLE_ID=${{ secrets.GOOGLE_ID }} -d --name web-app --restart unless-stopped -p 3005:3000 akshatwork6/user-app-image:latest

0 comments on commit 576426d

Please sign in to comment.