diff --git a/.github/workflows/backend-ci.yml b/.github/workflows/backend-build.yml similarity index 66% rename from .github/workflows/backend-ci.yml rename to .github/workflows/backend-build.yml index 1dc07c9..50e778f 100644 --- a/.github/workflows/backend-ci.yml +++ b/.github/workflows/backend-build.yml @@ -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: @@ -15,11 +30,12 @@ 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 @@ -27,7 +43,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v3 with: - python-version: '3.10' + python-version: ${{ github.event.inputs.pythonVersion }} - name: Install pipenv run: | diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..e6fbcf7 --- /dev/null +++ b/.github/workflows/build.yml @@ -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' \ 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..d5e3f7d --- /dev/null +++ b/.github/workflows/release.yml @@ -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 + 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/.gitkeep similarity index 100% rename from frontend/src/hooks/.keep rename to frontend/src/hooks/.gitkeep diff --git a/frontend/src/pages/BidderLogInPage.jsx b/frontend/src/pages/BidderLogInPage.jsx index 6817960..c9c61ff 100644 --- a/frontend/src/pages/BidderLogInPage.jsx +++ b/frontend/src/pages/BidderLogInPage.jsx @@ -82,4 +82,4 @@ export default function BidderLogInPage() { ); -} +} \ No newline at end of file diff --git a/frontend/src/pages/HomePage.jsx b/frontend/src/pages/HomePage.jsx index 1af1311..13d4656 100644 --- a/frontend/src/pages/HomePage.jsx +++ b/frontend/src/pages/HomePage.jsx @@ -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 (
+
); } diff --git a/frontend/src/utils/.keep b/frontend/src/utils/.gitkeep similarity index 100% rename from frontend/src/utils/.keep rename to frontend/src/utils/.gitkeep