From c7649d59b838eabd3fe30b741e50019ed0c3f627 Mon Sep 17 00:00:00 2001 From: Lance Tan Date: Sun, 4 Feb 2024 15:10:44 -0800 Subject: [PATCH] Deploy frontend --- .../{backend-ci.yml => backend/build.yml} | 24 ++++-- .github/workflows/build.yml | 24 ++++++ .../{frontend-ci.yml => frontend/build.yml} | 11 +-- .github/workflows/release.yml | 36 ++++++++ backend/core/settings.py | 37 ++++---- frontend/src/hooks/.keep | 0 frontend/src/pages/BidderLogInPage.jsx | 85 ------------------- frontend/src/utils/.keep | 0 8 files changed, 102 insertions(+), 115 deletions(-) rename .github/workflows/{backend-ci.yml => backend/build.yml} (74%) create mode 100644 .github/workflows/build.yml rename .github/workflows/{frontend-ci.yml => frontend/build.yml} (76%) create mode 100644 .github/workflows/release.yml delete mode 100644 frontend/src/hooks/.keep delete mode 100644 frontend/src/pages/BidderLogInPage.jsx delete mode 100644 frontend/src/utils/.keep diff --git a/.github/workflows/backend-ci.yml b/.github/workflows/backend/build.yml similarity index 74% rename from .github/workflows/backend-ci.yml rename to .github/workflows/backend/build.yml index 1dc07c9..2b8e991 100644 --- a/.github/workflows/backend-ci.yml +++ b/.github/workflows/backend/build.yml @@ -1,10 +1,22 @@ -name: Build Pipeline for Python and Django +name: Backend Build Pipeline on: - push: - branches: [ main ] - pull_request: - branches: [ main ] + workflow_call: + inputs: + pythonVersion: + required: true + type: string + secrets: + SECRET_KEY: + required: true + AWS_ACCESS_KEY_ID: + required: true + AWS_SECRET_ACCESS_KEY: + required: true + AWS_STORAGE_BUCKET_NAME: + required: true + AWS_S3_REGION_NAME: + required: true jobs: build: @@ -15,7 +27,7 @@ jobs: working-directory: ./backend env: - SECRET_KEY: ${{ secrets.DJANGO_SECRET }} + SECRET_KEY: ${{ secrets.SECRET_KEY }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_STORAGE_BUCKET_NAME: ${{ secrets.AWS_STORAGE_BUCKET_NAME }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..3e01ffb --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,24 @@ +name: Build + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + call-backend-build: + uses: ./.github/workflows/backend/build.yml + with: + pythonVersion: '3.10' + secrets: + SECRET_KEY: ${{ secrets.DJANGO_SECRET }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_STORAGE_BUCKET_NAME: ${{ secrets.AWS_STORAGE_BUCKET_NAME }} + AWS_S3_REGION_NAME: ${{ secrets.AWS_S3_REGION_NAME }} + + call-frontend-build: + uses: ./.github/workflows/frontend/build.yml + with: + nodeVersion: '20.x' \ No newline at end of file diff --git a/.github/workflows/frontend-ci.yml b/.github/workflows/frontend/build.yml similarity index 76% rename from .github/workflows/frontend-ci.yml rename to .github/workflows/frontend/build.yml index bb829e6..32fc49d 100644 --- a/.github/workflows/frontend-ci.yml +++ b/.github/workflows/frontend/build.yml @@ -1,10 +1,11 @@ -name: Build Pipeline for Node and React +name: Frontend Build Pipeline on: - push: - branches: [ main ] - pull_request: - branches: [ main ] + workflow_call: + inputs: + nodeVersion: + required: true + type: string jobs: build: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..49bd3f8 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,36 @@ +name: Deploy Frontend + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: '14' + + - name: Install dependencies + run: npm install + + - name: Build app + run: npm run build + + - name: Upload to S3 + uses: jakejarvis/s3-sync-action@master + with: + args: --acl public-read + env: + SOURCE_DIR: build/ + AWS_S3_BUCKET: ${{ secrets.AWS_S3_FRONTEND_BUCKET }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} diff --git a/backend/core/settings.py b/backend/core/settings.py index f00be11..fd197a6 100644 --- a/backend/core/settings.py +++ b/backend/core/settings.py @@ -33,7 +33,7 @@ # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True -ALLOWED_HOSTS = [] +ALLOWED_HOSTS = ["*"] # Application definition @@ -93,27 +93,26 @@ WSGI_APPLICATION = "core.wsgi.application" - # Database # https://docs.djangoproject.com/en/4.2/ref/settings/#databases -"""""" -DATABASES = { - "default": { - "ENGINE": "django.db.backends.sqlite3", - "NAME": os.path.join(BASE_DIR, "db.sqlite3"), - }, -} - -""" - 'default': { - 'ENGINE': 'django.db.backends.postgresql_psycopg2', - 'NAME': env("DB_NAME"), - 'USER': env("DB_USER"), - 'PASSWORD': env("DB_PASSWORD"), - 'HOST': env("DB_HOST"), - 'PORT': env("DB_PORT"), +if env("ENVIRONMENT") == 'prod': + DATABASES = { + "default": { + 'ENGINE': 'django.db.backends.postgresql', + 'NAME': os.environ.get('RDS_DB_NAME', 'your_database_name'), + 'USER': os.environ.get('RDS_USERNAME', 'your_username'), + 'PASSWORD': os.environ.get('RDS_PASSWORD', 'your_password'), + 'HOST': os.environ.get('RDS_HOSTNAME', 'your_rds_endpoint'), + 'PORT': os.environ.get('RDS_PORT', '5432'), + } + } +else: # Assuming 'dev' or any other value will use SQLite + DATABASES = { + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": os.path.join(BASE_DIR, "db.sqlite3"), + }, } -""" # Password validation # https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators diff --git a/frontend/src/hooks/.keep b/frontend/src/hooks/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/frontend/src/pages/BidderLogInPage.jsx b/frontend/src/pages/BidderLogInPage.jsx deleted file mode 100644 index 6817960..0000000 --- a/frontend/src/pages/BidderLogInPage.jsx +++ /dev/null @@ -1,85 +0,0 @@ -import React, { useState } from 'react'; -import { useNavigate } from 'react-router'; -import logo from '../assets/microvan_logo.svg'; -import OnboardingInputField from '../components/inputs/OnboardingInputField'; -import LogInButton from '../components/buttons/LogInButton'; - -export default function BidderLogInPage() { - const navigate = useNavigate(); - - const [email, setEmail] = useState(''); - const [password, setPassword] = useState(''); - - const handleEmailChange = (event) => setEmail(event.target.value); - const handlePasswordChange = (event) => setPassword(event.target.value); - - const handleLogIn = () => { - console.log(`Email: ${email}, Password: ${password}`); // eslint-disable-line no-console - }; - - return ( -
-
- -
- -
- -
- logo -

- Microvan Inc. -

-

Virtual Auctions

-
-

Email

- -
-
-

Password

- -
-
- -
- -
- -
- -
-

- © Microvan Inc. 2024 -

-
-
- ); -} diff --git a/frontend/src/utils/.keep b/frontend/src/utils/.keep deleted file mode 100644 index e69de29..0000000