From 636b8f8c1e288dc9ac57fa8132b3fbc2a19d975c Mon Sep 17 00:00:00 2001 From: cp-dharti-r Date: Thu, 9 May 2024 11:36:27 +0530 Subject: [PATCH] Setup to deploy website on s3 --- .github/workflows/deploy.yml | 78 +++++++------------ website/components/FoodCategory/index.tsx | 2 +- website/components/ItemCard/index.tsx | 2 +- website/components/YouMayLike/index.tsx | 2 +- website/next.config.mjs | 1 + website/pages/category/[category].tsx | 2 +- .../[restaurant]/categories/[category].tsx | 4 +- .../pages/restaurants/[restaurant]/index.tsx | 3 +- .../restaurants/[restaurant]/menus/[menu].tsx | 2 +- 9 files changed, 38 insertions(+), 58 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index cf45458..d353bd9 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,60 +1,38 @@ -name: Deploy website and admin panel +name: Deploy website and admin panel on s3 on: push: branches: - - main + - deploy-website-using-s3 jobs: - merge: - runs-on: ubuntu-latest + build-and-deploy: + name: Build and Deploy + runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 + steps: + - name: Checkout + uses: actions/checkout@v2 - - name: Fetch and reset main branch - run: | - git fetch origin main - git checkout main - git reset --hard origin/main + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: "20.x" - - name: Merge website branch to website-main - run: | - git fetch origin - git config user.name github-actions - git config user.email github-actions@github.com - if [ "$(git diff origin/main:website origin/website-main | wc -l)" -gt "0" ]; then - echo "Detected uncommitted changes in the website folder after build. Pushing changes to website-main branch." - git checkout website-main - git rm -r * - git checkout main -- website - git mv website/* . - ls - rm -r website - git add . - git commit -m "Deploy website" - git push origin website-main - else - echo "No changes detected in the website folder after build. Exiting." - fi + - name: Install dependencies and Build website + run: | + cd website + npm install + npm run build - - name: Merge admin branch to admin-main - run: | - git fetch origin - git config user.name github-actions - git config user.email github-actions@github.com - if [ "$(git diff origin/main:admin origin/admin-main | wc -l)" -gt "0" ]; then - echo "Detected uncommitted changes in the admin folder after build. Pushing changes to admin-main branch." - git checkout admin-main - git rm -r * - git checkout main -- admin - git mv admin/* . - ls - rm -r admin - git add . - git commit -m "Deploy admin panel" - git push origin admin-main - else - echo "No changes detected in the admin folder after build. Exiting." - fi + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION }} + + - name: Deploy to S3 + run: | + cd website + aws s3 sync ./out s3://${{ secrets.WEBSITE_BUCKET_NAME }} diff --git a/website/components/FoodCategory/index.tsx b/website/components/FoodCategory/index.tsx index 2d59169..d22b87c 100644 --- a/website/components/FoodCategory/index.tsx +++ b/website/components/FoodCategory/index.tsx @@ -55,7 +55,7 @@ const FoodCategory = () => { return ( <>
-
+
{ return (
-
+
{ return ( <>
-
+
{ <> {categoryData ? ( -
+
{ <> {categoryData ? ( <> -
+
@@ -199,7 +199,7 @@ const RestaurantCategory = () => {
-
+
-
+