Skip to content

Commit

Permalink
resolved-conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashutoshpadhi629 committed Sep 30, 2024
2 parents 9c42fb4 + 9f9e1d9 commit e5b9afb
Show file tree
Hide file tree
Showing 33 changed files with 621 additions and 8,120 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
node_modules
build
./apps/web/.env
./packages/db/.env
43 changes: 43 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Continuous Deployment
on:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Docker login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile.prod
push: true
tags: 100xdevs/dailycode-staging:${{ github.sha }}
build-args: |
DATABASE_URL=${{ secrets.STAGING_DATABASE }}
- name: Clone staging-ops repo, update, and push
env:
PAT: ${{ secrets.PAT }}
run: |
git clone https://github.com/code100x/staging-ops.git
cd staging-ops
sed -i 's|image: 100xdevs/dailycode-staging:.*|image: 100xdevs/dailycode-staging:${{ github.sha }}|' staging/dailycode/deployment.yml
git config user.name "GitHub Actions Bot"
git config user.email "[email protected]"
git add staging/dailycode/deployment.yml
git commit -m "Update dailycode image to ${{ github.sha }}"
git push https://${PAT}@github.com/code100x/staging-ops.git main
43 changes: 43 additions & 0 deletions .github/workflows/cd_prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Continuous Deployment (Prod)
on:
push:
branches: [ production ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Docker login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile.prod
push: true
tags: 100xdevs/dailycode:${{ github.sha }}
build-args: |
DATABASE_URL=${{ secrets.PROD_DATABASE }}
- name: Clone staging-ops repo, update, and push
env:
PAT: ${{ secrets.PAT }}
run: |
git clone https://github.com/code100x/staging-ops.git
cd staging-ops
sed -i 's|image: 100xdevs/dailycode:.*|image: 100xdevs/dailycode:${{ github.sha }}|' prod/dailycode/deployment.yml
git config user.name "GitHub Actions Bot"
git config user.email "[email protected]"
git add prod/dailycode/deployment.yml
git commit -m "Update dailycode image to ${{ github.sha }}"
git push https://${PAT}@github.com/code100x/staging-ops.git main
7 changes: 4 additions & 3 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"singleQuote": false,
"printWidth":120,
"printWidth": 120,
"bracketSpacing": true,
"tabWidth": 2,
"trailingComma": "es5",
"semi": true
}
"semi": true,
"plugins": ["prettier-plugin-tailwindcss"]
}
10 changes: 7 additions & 3 deletions Dockerfile.prod
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ ARG DATABASE_URL
WORKDIR /usr/src/app

COPY . .
RUN yarn install

RUN npm install
RUN cd packages/db && DATABASE_URL=$DATABASE_URL npx prisma generate && cd ../..
## put DATABASE_URL in apps/web/.env
RUN echo DATABASE_URL=$DATABASE_URL >> apps/web/.env
RUN DATABASE_URL=$DATABASE_URL npm run build
## Remove .env file
RUN rm apps/web/.env

EXPOSE 3000

CMD ["npm", "run", "start"]

CMD ["npm", "run", "start"]
6 changes: 3 additions & 3 deletions apps/web/app/admin/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ export default async function AdminLayout({ children }: { children: ReactNode })

if (!session?.user?.admin) {
return (
<div className="w-full min-h-screen flex items-center justify-center gap-4 p-4">
<div className="flex min-h-screen w-full items-center justify-center gap-4 p-4">
<div className="flex flex-col items-center justify-center space-y-4 text-center">
<div className="flex flex-col items-center space-y-2">
<LockClosedIcon className="w-14 h-14" />
<LockClosedIcon className="h-14 w-14" />
<div className="space-y-2">
<h1 className="text-3xl font-bold">Access Denied</h1>
<p className="text-sm text-gray-500 md:text-base dark:text-gray-400">
Expand All @@ -22,7 +22,7 @@ export default async function AdminLayout({ children }: { children: ReactNode })
</div>
<div className="flex flex-col gap-2 min-[400px]:flex-row">
<Link
className="inline-flex h-10 items-center justify-center rounded-md border border-gray-200 bg-white px-8 text-sm font-medium shadow-sm transition-colors hover:bg-gray-100 hover:text-gray-900 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-gray-950 disabled:pointer-events-none disabled:opacity-50 dark:border-gray-800 dark:bg-gray-950 dark:hover:bg-gray-800 dark:hover:text-gray-50 dark:focus-visible:ring-gray-300"
className="inline-flex h-10 items-center justify-center rounded-md border border-gray-200 bg-white px-8 text-sm font-medium shadow-sm transition-colors hover:bg-gray-100 hover:text-gray-900 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-gray-950 disabled:pointer-events-none disabled:opacity-50 dark:border-gray-800 dark:bg-gray-950 dark:hover:bg-gray-800 dark:hover:text-gray-50 dark:focus-visible:ring-gray-300"
href="/"
>
Return to the homepage
Expand Down
32 changes: 17 additions & 15 deletions apps/web/app/pdf/[...pdfId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ export default async function TrackComponent({ params }: { params: { pdfId: stri
if (problemDetails?.notionDocId && trackDetails?.problems) {
// notionRecordMaps = await notion.getPage(problemDetails.notionDocId);
notionRecordMaps = await Promise.all(
trackDetails.problems.map(async (problem: any) => await notion.getPage((await getProblem(problem.id))?.notionDocId!))
trackDetails.problems.map(
async (problem: any) => await notion.getPage((await getProblem(problem.id))?.notionDocId!)
)
);
}

Expand All @@ -36,20 +38,20 @@ export default async function TrackComponent({ params }: { params: { pdfId: stri
}
if (trackDetails && problemDetails) {
return (
<div>
{trackDetails?.problems.map((problem: any, i: number) => (
<LessonView
isPdfRequested={true}
track={trackDetails}
problem={{
...problemDetails,
notionRecordMap: notionRecordMaps[i],
}}
key={i}
/>
))}
<Print />
</div>
<div>
{trackDetails?.problems.map((problem: any, i: number) => (
<LessonView
isPdfRequested
track={trackDetails}
problem={{
...problemDetails,
notionRecordMap: notionRecordMaps[i],
}}
key={i}
/>
))}
<Print />
</div>
);
}
}
1 change: 1 addition & 0 deletions apps/web/app/tracks/[...trackIds]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export default async function TrackComponent({ params }: { params: { trackIds: s
return (
<LessonView
showAppBar
showPagination
track={trackDetails}
problem={{
...problemDetails,
Expand Down
45 changes: 33 additions & 12 deletions apps/web/components/Blog.tsx
Original file line number Diff line number Diff line change
@@ -1,40 +1,61 @@
"use client";
import { useRecoilValue } from "recoil";

import { Problem, Track } from "@prisma/client";
import { isLegacyViewMode } from "@repo/store";

import { BlogAppbar } from "./BlogAppbar";
import { NotionRenderer } from "./NotionRenderer";
import useMountStatus from "../hooks/useMountStatus";
import TrackTools from "./TrackTools";
import CustomPagination from "./CustomPagination";

export const Blog = ({
problem,
track,
showAppBar,
showPagination,
isPdfRequested,
problemIndex,
}: {
problem: Problem & { notionRecordMap: any };
track: Track & { problems: Problem[] };
showAppBar: Boolean;
isPdfRequested?: Boolean;
showAppBar?: boolean;
showPagination?: boolean;
isPdfRequested?: boolean;
problemIndex: number;
}) => {
const mounted = useMountStatus();
const isLegacyMode = useRecoilValue(isLegacyViewMode);

if (isPdfRequested == undefined || !isPdfRequested) {
if (!mounted) {
return null;
}
}

return (
<div>
<NotionRenderer recordMap={problem.notionRecordMap} />
<div className="fixed top-0 w-full">
<BlogAppbar problem={problem} track={track} problemIndex={problemIndex} />
const renderBlog = () =>
isLegacyMode ? (
<div className="break-after-page">
{showAppBar && <BlogAppbar problem={problem} track={track} problemIndex={problemIndex} />}
<NotionRenderer recordMap={problem.notionRecordMap} />
{showPagination && (
<div className="justify-center pt-2">
<CustomPagination allProblems={track.problems} track={track} problemIndex={problemIndex} />
</div>
)}
</div>
<div className="fixed bottom-0 itemsc-center justify-center mx-auto w-full">
<TrackTools allProblems={track.problems} track={track} problemIndex={problemIndex} />
) : (
<div>
<NotionRenderer recordMap={problem.notionRecordMap} />
<div className="fixed top-0 w-full">
<BlogAppbar problem={problem} track={track} problemIndex={problemIndex} />
</div>
<div className="itemsc-center fixed bottom-0 mx-auto w-full justify-center">
<TrackTools allProblems={track.problems} track={track} problemIndex={problemIndex} />
</div>
</div>
</div>
);
);

return renderBlog();
};

Loading

0 comments on commit e5b9afb

Please sign in to comment.