From fa7c53015d9ed534c3de2d86e5c24c70b3e32d09 Mon Sep 17 00:00:00 2001 From: Ajith Teja Date: Wed, 13 Nov 2024 02:48:49 +0530 Subject: [PATCH 1/4] added workflow --- .github/workflows/build.yml | 3 --- .github2/workflows/build.yml | 25 ++++++++++++++++++++++ {.github => .github2}/workflows/deploy.yml | 0 3 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 .github2/workflows/build.yml rename {.github => .github2}/workflows/deploy.yml (100%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c8b64f0e..f691d9cd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,9 +17,6 @@ jobs: - name: Install Dependencies run: npm install - - - name: Generate prisma client - run: npm run db:generate - name: Run Build run: npm run build diff --git a/.github2/workflows/build.yml b/.github2/workflows/build.yml new file mode 100644 index 00000000..c8b64f0e --- /dev/null +++ b/.github2/workflows/build.yml @@ -0,0 +1,25 @@ +name: Build on PR + +on: + pull_request: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: '20' + + - name: Install Dependencies + run: npm install + + - name: Generate prisma client + run: npm run db:generate + + - name: Run Build + run: npm run build diff --git a/.github/workflows/deploy.yml b/.github2/workflows/deploy.yml similarity index 100% rename from .github/workflows/deploy.yml rename to .github2/workflows/deploy.yml From a81b0f6543286c51b4615099e9257a847568677a Mon Sep 17 00:00:00 2001 From: Ajith Teja Date: Wed, 13 Nov 2024 03:04:37 +0530 Subject: [PATCH 2/4] added db:generate --- .github/workflows/build.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f691d9cd..633d743c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,5 +18,8 @@ jobs: - name: Install Dependencies run: npm install + - name: Generate Prisma + run: npm run db:generate + - name: Run Build run: npm run build From 38e1a048e8197de23974d3c18bfa0e41541c4b51 Mon Sep 17 00:00:00 2001 From: Ajith Teja Date: Wed, 13 Nov 2024 03:08:26 +0530 Subject: [PATCH 3/4] added changes --- apps/user-app/app/page.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/user-app/app/page.tsx b/apps/user-app/app/page.tsx index 0288eb02..b80f035a 100644 --- a/apps/user-app/app/page.tsx +++ b/apps/user-app/app/page.tsx @@ -5,6 +5,9 @@ import { authOptions } from "./lib/auth"; export default async function Page() { const session = await getServerSession(authOptions); if (session?.user) { + + + redirect('/dashboard') } else { redirect('/api/auth/signin') From e7af8945fef6bbd19c76bf5d7e2f872e6c21ddc1 Mon Sep 17 00:00:00 2001 From: Ajith Teja Date: Wed, 13 Nov 2024 03:57:07 +0530 Subject: [PATCH 4/4] added deploy workflow --- .Dockerfile | 18 ++++++++++++++++++ .github/workflows/build.yml | 4 ++-- {.github2 => .github}/workflows/deploy.yml | 8 ++++---- {.github2 => .github22}/workflows/build.yml | 4 ++-- 4 files changed, 26 insertions(+), 8 deletions(-) create mode 100644 .Dockerfile rename {.github2 => .github}/workflows/deploy.yml (71%) rename {.github2 => .github22}/workflows/build.yml (90%) diff --git a/.Dockerfile b/.Dockerfile new file mode 100644 index 00000000..d8cde5b1 --- /dev/null +++ b/.Dockerfile @@ -0,0 +1,18 @@ +FROM node:20.12.0-alpine3.19 + +WORKDIR /usr/src/app + +COPY package.json package-lock.json turbo.json tsconfig.json ./ + +COPY apps ./apps +COPY packages ./packages + +# Install dependencies +RUN npm install +# Can you add a script to the global package.json that does this? +RUN npm run db:generate + +# Can you filter the build down to just one app? +RUN npm run build + +CMD ["npm", "run", "start-user-app"] \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 633d743c..c8b64f0e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,8 +17,8 @@ jobs: - name: Install Dependencies run: npm install - - - name: Generate Prisma + + - name: Generate prisma client run: npm run db:generate - name: Run Build diff --git a/.github2/workflows/deploy.yml b/.github/workflows/deploy.yml similarity index 71% rename from .github2/workflows/deploy.yml rename to .github/workflows/deploy.yml index acbed6e5..20310053 100644 --- a/.github2/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -24,10 +24,10 @@ jobs: context: . file: ./docker/Dockerfile.user push: true - tags: 100xdevs/week-18-class:latest # Replace with your Docker Hub username and repository + tags: ajithteja/week-18-class:latest # Replace with your Docker Hub username and repository - name: Verify Pushed Image - run: docker pull 100xdevs/week-18-class:latest # Replace with your Docker Hub username and repository + run: docker pull ajithteja/week-18-class:latest # Replace with your Docker Hub username and repository - name: Deploy to EC2 uses: appleboy/ssh-action@master @@ -36,7 +36,7 @@ jobs: username: ${{ secrets.SSH_USERNAME }} key: ${{ secrets.SSH_KEY }} script: | - sudo docker pull 100xdevs/week-18-class:latest + sudo docker pull ajithteja/week-18-class:latest sudo docker stop web-app || true sudo docker rm web-app || true - sudo docker run -d --name web-app -p 3005:3000 100xdevs/week-18-class:latest \ No newline at end of file + sudo docker run -d --name web-app -p 3005:3000 ajithteja/week-18-class:latest \ No newline at end of file diff --git a/.github2/workflows/build.yml b/.github22/workflows/build.yml similarity index 90% rename from .github2/workflows/build.yml rename to .github22/workflows/build.yml index c8b64f0e..633d743c 100644 --- a/.github2/workflows/build.yml +++ b/.github22/workflows/build.yml @@ -17,8 +17,8 @@ jobs: - name: Install Dependencies run: npm install - - - name: Generate prisma client + + - name: Generate Prisma run: npm run db:generate - name: Run Build