Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
KrishDave1 committed Nov 16, 2024
2 parents 4ab9c19 + daf136c commit 8f6afab
Show file tree
Hide file tree
Showing 3 changed files with 746 additions and 0 deletions.
113 changes: 113 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: Sync CI/CD Workflow

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:
runs-on: ubuntu-latest

steps:
# Step 1: Check out the repository
- name: Checkout code
uses: actions/checkout@v4

# Step 2: Set up Node.js
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: 20 # Specify the Node.js version
cache: 'npm'

# Step 3: Install dependencies
- name: Install dependencies
run: npm install

# Step 4: Build the Next.js project
- name: Build the Next.js application
run: npm run build
env:
UPSTASH_REDIS_REST_URL: ${{ secrets.UPSTASH_REDIS_REST_URL }}
UPSTASH_REDIS_REST_TOKEN: ${{ secrets.UPSTASH_REDIS_REST_TOKEN }}
GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }}
GOOGLE_CLIENT_SECRET: ${{ secrets.GOOGLE_CLIENT_SECRET }}
NEXTAUTH_SECRET: ${{ secrets.NEXTAUTH_SECRET }}
PUSHER_APP_ID: ${{ secrets.PUSHER_APP_ID }}
NEXT_PUBLIC_PUSHER_KEY: ${{ secrets.NEXT_PUBLIC_PUSHER_KEY }}
PUSHER_SECRET: ${{ secrets.PUSHER_SECRET }}
PUSHER_CLUSTER: ${{ secrets.PUSHER_CLUSTER }}
NEXTAUTH_URL: ${{ secrets.NEXTAUTH_URL }}

# Step 5: Upload build artifacts (optional)
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: nextjs-build
path: .next
include-hidden-files: true
if-no-files-found: warn

# Step 6: Build and Push Docker Image
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and Push Docker Image
run: |
IMAGE_NAME=${{ secrets.DOCKER_IMAGE_NAME }}:latest
docker buildx build \
--build-arg UPSTASH_REDIS_REST_URL=${{ secrets.UPSTASH_REDIS_REST_URL }} \
--build-arg UPSTASH_REDIS_REST_TOKEN=${{ secrets.UPSTASH_REDIS_REST_TOKEN }} \
--build-arg GOOGLE_CLIENT_ID= ${{ secrets.GOOGLE_CLIENT_ID }} \
--build-arg GOOGLE_CLIENT_SECRET= ${{ secrets.GOOGLE_CLIENT_SECRET }} \
--build-arg NEXTAUTH_SECRET= ${{ secrets.NEXTAUTH_SECRET }} \
--build-arg PUSHER_APP_ID= ${{ secrets.PUSHER_APP_ID }} \
--build-arg NEXT_PUBLIC_PUSHER_KEY= ${{ secrets.NEXT_PUBLIC_PUSHER_KEY }} \
--build-arg PUSHER_SECRET= ${{ secrets.PUSHER_SECRET }} \
--build-arg PUSHER_CLUSTER= ${{ secrets.PUSHER_CLUSTER }} \
--build-arg NEXTAUTH_URL= ${{ secrets.NEXTAUTH_URL }} \
-t $IMAGE_NAME .
docker push $IMAGE_NAME
deploy:
runs-on: ubuntu-latest
needs: build

steps:
# Step 1: Checkout code
- name: Checkout code
uses: actions/checkout@v4

# Step 2: Setup Node.js
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: 20 # Specify the Node.js version
cache: 'npm'

# Step 3: Download build artifacts
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: nextjs-build

# Step 4: Deploy to Vercel
- name: Deploy to Vercel
run: npx vercel --prod
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
UPSTASH_REDIS_REST_URL: ${{ secrets.UPSTASH_REDIS_REST_URL }}
UPSTASH_REDIS_REST_TOKEN: ${{ secrets.UPSTASH_REDIS_REST_TOKEN }}
GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }}
GOOGLE_CLIENT_SECRET: ${{ secrets.GOOGLE_CLIENT_SECRET }}
NEXTAUTH_SECRET: ${{ secrets.NEXTAUTH_SECRET }}
PUSHER_APP_ID: ${{ secrets.PUSHER_APP_ID }}
NEXT_PUBLIC_PUSHER_KEY: ${{ secrets.NEXT_PUBLIC_PUSHER_KEY }}
PUSHER_SECRET: ${{ secrets.PUSHER_SECRET }}
PUSHER_CLUSTER: ${{ secrets.PUSHER_CLUSTER }}
NEXTAUTH_URL: ${{ secrets.NEXTAUTH_URL }}
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Sync - Realtime Messaging Chat Application

<p align="center">
<!-- local repository, no metadata badges. --></p>
<p align="center">Built with the tools and technologies:</p>
<p align="center">
<img src="https://img.shields.io/badge/npm-CB3837.svg?style=default&logo=npm&logoColor=white" alt="npm">
<img src="https://img.shields.io/badge/PostCSS-DD3A0A.svg?style=default&logo=PostCSS&logoColor=white" alt="PostCSS">
<img src="https://img.shields.io/badge/JavaScript-F7DF1E.svg?style=default&logo=JavaScript&logoColor=black" alt="JavaScript">
<img src="https://img.shields.io/badge/sharp-99CC00.svg?style=default&logo=sharp&logoColor=white" alt="sharp">
<img src="https://img.shields.io/badge/React-61DAFB.svg?style=default&logo=React&logoColor=black" alt="React">
<img src="https://img.shields.io/badge/Docker-2496ED.svg?style=default&logo=Docker&logoColor=white" alt="Docker">
<br>
<img src="https://img.shields.io/badge/TypeScript-3178C6.svg?style=default&logo=TypeScript&logoColor=white" alt="TypeScript">
<img src="https://img.shields.io/badge/Zod-3E67B1.svg?style=default&logo=Zod&logoColor=white" alt="Zod">
<img src="https://img.shields.io/badge/ESLint-4B32C3.svg?style=default&logo=ESLint&logoColor=white" alt="ESLint">
<img src="https://img.shields.io/badge/Axios-5A29E4.svg?style=default&logo=Axios&logoColor=white" alt="Axios">
<img src="https://img.shields.io/badge/Pusher-300D4F.svg?style=default&logo=Pusher&logoColor=white" alt="Pusher">
<img src="https://img.shields.io/badge/datefns-770C56.svg?style=default&logo=date-fns&logoColor=white" alt="datefns">
</p>

<br />

## Introduction
Sync is a real-time messaging chat application designed for developers. It offers a seamless and responsive user experience with features like real-time messaging, friend requests, and Google authentication. The application is built using modern technologies such as TypeScript, Tailwind CSS, and Next.js, ensuring high performance and scalability.

Expand Down
Loading

0 comments on commit 8f6afab

Please sign in to comment.