Skip to content

Commit

Permalink
Merge pull request #14 from Somnath-Chattaraj/test2
Browse files Browse the repository at this point in the history
Add CI/CD pipeline
  • Loading branch information
Somnath-Chattaraj authored Jul 29, 2024
2 parents 0b88801 + 13805d7 commit 302eb49
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Build and Migrate

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
cache: 'npm'

- name: Navigate to backend directory
run: cd backend

- name: Install dependencies
run: npm install
working-directory: backend

- name: Build code
run: npm run build
working-directory: backend

- name: Set up Prisma
run: npx prisma generate
working-directory: backend

- name: Run Prisma Migrate
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
run: npx prisma migrate deploy
working-directory: backend
30 changes: 30 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Build and Deploy to Docker Hub

on:
push:
branches:
- master

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: Build and Push Docker image
uses: docker/build-push-action@v2
with:
context: .
file: ./backend/Dockerfile
push: true
tags: somnath910/statuscode1:latest # Replace with your Docker Hub username and repository

- name: Verify Pushed Image
run: docker pull somnath910/statuscode1:latest # Replace with your Docker Hub username and repository

0 comments on commit 302eb49

Please sign in to comment.