Skip to content

Commit

Permalink
Merge a999784 into d4261db
Browse files Browse the repository at this point in the history
  • Loading branch information
ltan02 authored Feb 5, 2024
2 parents d4261db + a999784 commit e5d7ddd
Show file tree
Hide file tree
Showing 9 changed files with 161 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
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
environment:
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:
Expand All @@ -15,19 +30,20 @@ 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 }}
AWS_S3_REGION_NAME: ${{ secrets.AWS_S3_REGION_NAME }}
ENVIRONMENT: ${{ github.event.inputs.environment }}

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.10'
python-version: ${{ github.event.inputs.pythonVersion }}

- name: Install pipenv
run: |
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Build

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
call-backend-build:
uses: ./.github/workflows/backend-build.yml
with:
pythonVersion: '3.10'
environment: ${{ github.event_name == 'push' && 'prod' || 'dev' }}
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'
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
84 changes: 84 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Deploy Resources

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
deploy-frontend:
name: Deploy Frontend
runs-on: ubuntu-latest
defaults:
run:
shell: bash
working-directory: ./frontend

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20.x'

- name: Install dependencies
run: npm install

- name: Build the project
run: npm run build

- 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: ap-southeast-1

- name: Install AWS Amplify CLI
run: npm install -g @aws-amplify/cli

- name: Deploy to Amplify
run: |
amplify init --yes
amplify publish --yes
create-release:
name: Create Release
runs-on: ubuntu-latest
needs: [ deploy-frontend ]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Prepare release
id: prep_release
run: |
# Example script to generate tag and release notes, needs to be customized
TAG_NAME=$(git tag --sort=-v:refname | head -n 1 | awk -F '.' '{print $1 "." $2+1}')
if [ -z "$TAG_NAME" ]; then
TAG_NAME="1.0"
fi
RELEASE_NOTES=$(git log $(git describe --tags --abbrev=0)..HEAD --oneline)
if [ -z "$RELEASE_NOTES" ]; then
RELEASE_NOTES="Initial release"
fi
echo "::set-output name=tag_name::$TAG_NAME"
echo "::set-output name=release_notes::$RELEASE_NOTES"
shell: bash

- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.prep_release.outputs.tag_name }}
release_name: Release ${{ steps.prep_release.outputs.tag_name }}
body: ${{ steps.prep_release.outputs.release_notes }}
draft: false
prerelease: false

37 changes: 18 additions & 19 deletions backend/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []
ALLOWED_HOSTS = ["*"]


# Application definition
Expand Down Expand Up @@ -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
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion frontend/src/pages/BidderLogInPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ export default function BidderLogInPage() {
</div>
</div>
);
}
}
4 changes: 4 additions & 0 deletions frontend/src/pages/HomePage.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import React from 'react';
import { useNavigate } from "react-router";
import NavBar from '../components/nav-bar/NavBar';

export default function HomePage() {
const navigate = useNavigate();

return (
<div className="App">
<NavBar />
<button type="button" className="btn btn-primary" onClick={() => navigate("/onboard")}>Click me</button>
</div>
);
}
File renamed without changes.

0 comments on commit e5d7ddd

Please sign in to comment.