diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..7d68f89 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -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 }} diff --git a/README.md b/README.md index 7e93753..90cb93c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,26 @@ # Sync - Realtime Messaging Chat Application +

+

+

Built with the tools and technologies:

+

+ npm + PostCSS + JavaScript + sharp + React + Docker +
+ TypeScript + Zod + ESLint + Axios + Pusher + datefns +

+ +
+ ## 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. diff --git a/readme-ai.md b/readme-ai.md new file mode 100644 index 0000000..fcf86e2 --- /dev/null +++ b/readme-ai.md @@ -0,0 +1,612 @@ +

+ +

+

❯ REPLACE-ME

+

+ ❯ REPLACE-ME +

+

+

+

Built with the tools and technologies:

+

+ npm + PostCSS + JavaScript + sharp + React + Docker +
+ TypeScript + Zod + ESLint + Axios + Pusher + datefns +

+
+ +## Table of Contents + +- [ Overview](#-overview) +- [ Features](#-features) +- [ Project Structure](#-project-structure) + - [ Project Index](#-project-index) +- [ Getting Started](#-getting-started) + - [ Prerequisites](#-prerequisites) + - [ Installation](#-installation) + - [ Usage](#-usage) + - [ Testing](#-testing) +- [ Project Roadmap](#-project-roadmap) +- [ Contributing](#-contributing) +- [ License](#-license) +- [ Acknowledgments](#-acknowledgments) + +--- + +## Overview + +❯ REPLACE-ME + +--- + +## Features + +❯ REPLACE-ME + +--- + +## Project Structure + +```sh +└── / + ├── bun.lockb + ├── components.json + ├── Dockerfile + ├── next.config.mjs + ├── package-lock.json + ├── package.json + ├── postcss.config.mjs + ├── public + │ └── favicon.ico + ├── README.md + ├── src + │ ├── app + │ ├── components + │ ├── context + │ ├── helpers + │ ├── lib + │ ├── middleware.ts + │ ├── schemas + │ └── types + ├── tailwind.config.ts + └── tsconfig.json +``` + + +### Project Index +
+ / +
+ __root__ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
components.json❯ REPLACE-ME
Dockerfile❯ REPLACE-ME
next.config.mjs❯ REPLACE-ME
package-lock.json❯ REPLACE-ME
package.json❯ REPLACE-ME
postcss.config.mjs❯ REPLACE-ME
tailwind.config.ts❯ REPLACE-ME
tsconfig.json❯ REPLACE-ME
+
+
+
+ src +
+ + + + + +
middleware.ts❯ REPLACE-ME
+
+ app +
+ + + + + + + + + + + + + +
globals.css❯ REPLACE-ME
layout.tsx❯ REPLACE-ME
page.tsx❯ REPLACE-ME
+
+ (auth) +
+
+ login +
+ + + + + +
page.tsx❯ REPLACE-ME
+
+
+
+
+
+ (dashboard) +
+
+ dashboard +
+ + + + + + + + + +
layout.tsx❯ REPLACE-ME
page.tsx❯ REPLACE-ME
+
+ add +
+ + + + + + + + + +
loading.tsx❯ REPLACE-ME
page.tsx❯ REPLACE-ME
+
+
+
+ chat +
+
+ [chatId] +
+ + + + + + + + + +
loading.tsx❯ REPLACE-ME
page.tsx❯ REPLACE-ME
+
+
+
+
+
+ requests +
+ + + + + + + + + +
loading.tsx❯ REPLACE-ME
page.tsx❯ REPLACE-ME
+
+
+
+
+
+
+
+ api +
+
+ auth +
+
+ [...nextauth] +
+ + + + + + + + + +
options.ts❯ REPLACE-ME
route.ts❯ REPLACE-ME
+
+
+
+
+
+ friends +
+
+ accept +
+ + + + + +
route.ts❯ REPLACE-ME
+
+
+
+ add +
+ + + + + +
route.ts❯ REPLACE-ME
+
+
+
+ deny +
+ + + + + +
route.ts❯ REPLACE-ME
+
+
+
+
+
+ message +
+
+ send +
+ + + + + +
route.ts❯ REPLACE-ME
+
+
+
+
+
+
+
+
+
+ components +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AddFriendButton.tsx❯ REPLACE-ME
ChatInput.tsx❯ REPLACE-ME
FriendRequests.tsx❯ REPLACE-ME
FriendRequestsSidebarOptions.tsx❯ REPLACE-ME
Icons.tsx❯ REPLACE-ME
Messages.tsx❯ REPLACE-ME
MobileChatLayout.tsx❯ REPLACE-ME
SidebarChatList.tsx❯ REPLACE-ME
SignOutButton.tsx❯ REPLACE-ME
UnseenChatToast.tsx❯ REPLACE-ME
+
+ ui +
+ + + + + + + + + + + + + + + + + +
Button.tsx❯ REPLACE-ME
toast.tsx❯ REPLACE-ME
toaster.tsx❯ REPLACE-ME
use-toast.ts❯ REPLACE-ME
+
+
+
+
+
+ context +
+ + + + + +
AuthProvider.tsx❯ REPLACE-ME
+
+
+
+ helpers +
+ + + + + + + + + +
get-friends-by-userId.ts❯ REPLACE-ME
redis.ts❯ REPLACE-ME
+
+
+
+ lib +
+ + + + + + + + + + + + + +
db.ts❯ REPLACE-ME
pusher.ts❯ REPLACE-ME
utils.ts❯ REPLACE-ME
+
+
+
+ schemas +
+ + + + + + + + + +
addFriend.ts❯ REPLACE-ME
message.ts❯ REPLACE-ME
+
+
+
+ types +
+ + + + + + + + + + + + + + + + + +
db.d.ts❯ REPLACE-ME
next-auth.d.ts❯ REPLACE-ME
pusher.d.ts❯ REPLACE-ME
typing.d.ts❯ REPLACE-ME
+
+
+
+
+
+ +--- +## Getting Started + +### Prerequisites + +Before getting started with , ensure your runtime environment meets the following requirements: + +- **Programming Language:** TypeScript +- **Package Manager:** Npm +- **Container Runtime:** Docker + + +### Installation + +Install using one of the following methods: + +**Build from source:** + +1. Clone the repository: +```sh +❯ git clone ../ +``` + +2. Navigate to the project directory: +```sh +❯ cd +``` + +3. Install the project dependencies: + + +**Using `npm`**   [](https://www.npmjs.com/) + +```sh +❯ npm install +``` + + +**Using `docker`**   [](https://www.docker.com/) + +```sh +❯ docker build -t / . +``` + + + + +### Usage +Run using the following command: +**Using `npm`**   [](https://www.npmjs.com/) + +```sh +❯ npm start +``` + + +**Using `docker`**   [](https://www.docker.com/) + +```sh +❯ docker run -it {image_name} +``` + + +### Testing +Run the test suite using the following command: +**Using `npm`**   [](https://www.npmjs.com/) + +```sh +❯ npm test +``` + + +--- +## Project Roadmap + +- [X] **`Task 1`**: Implement feature one. +- [ ] **`Task 2`**: Implement feature two. +- [ ] **`Task 3`**: Implement feature three. + +--- + +## Contributing + +- **💬 [Join the Discussions](https://LOCAL///discussions)**: Share your insights, provide feedback, or ask questions. +- **🐛 [Report Issues](https://LOCAL///issues)**: Submit bugs found or log feature requests for the `` project. +- **💡 [Submit Pull Requests](https://LOCAL///blob/main/CONTRIBUTING.md)**: Review open PRs, and submit your own PRs. + +
+Contributing Guidelines + +1. **Fork the Repository**: Start by forking the project repository to your LOCAL account. +2. **Clone Locally**: Clone the forked repository to your local machine using a git client. + ```sh + git clone . + ``` +3. **Create a New Branch**: Always work on a new branch, giving it a descriptive name. + ```sh + git checkout -b new-feature-x + ``` +4. **Make Your Changes**: Develop and test your changes locally. +5. **Commit Your Changes**: Commit with a clear message describing your updates. + ```sh + git commit -m 'Implemented new feature x.' + ``` +6. **Push to LOCAL**: Push the changes to your forked repository. + ```sh + git push origin new-feature-x + ``` +7. **Submit a Pull Request**: Create a PR against the original project repository. Clearly describe the changes and their motivations. +8. **Review**: Once your PR is reviewed and approved, it will be merged into the main branch. Congratulations on your contribution! +
+ +
+Contributor Graph +
+

+ + + +

+
+ +--- + +## License + +This project is protected under the [SELECT-A-LICENSE](https://choosealicense.com/licenses) License. For more details, refer to the [LICENSE](https://choosealicense.com/licenses/) file. + +--- + +## Acknowledgments + +- List any resources, contributors, inspiration, etc. here. + +---