Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanPham9x authored Mar 28, 2024
2 parents 20cedd9 + 2f46f47 commit d85b3d7
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Azure Static Web Apps CI/CD

on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- main

jobs:
build_and_deploy_job:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
name: Build and Deploy Job
steps:
- uses: actions/checkout@v3
with:
submodules: true
lfs: false
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_AMBITIOUS_BEACH_08301CF10 }}
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
action: "upload"
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
app_location: "/frontend" # App source code path
api_location: "" # Api source code path - optional
output_location: "build" # Built app content directory - optional
###### End of Repository/Build Configurations ######
env: # Add environment variables here
REACT_APP_API_BASE_URL: ${{ secrets.REACT_APP_API_BASE_URL}}

close_pull_request_job:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
name: Close Pull Request Job
steps:
- name: Close Pull Request
id: closepullrequest
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_AMBITIOUS_BEACH_08301CF10 }}
action: "close"
78 changes: 78 additions & 0 deletions .github/workflows/main_cs4353.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions
# More info on Python, GitHub Actions, and Azure App Service: https://aka.ms/python-webapps-actions

name: Build and deploy Python app to Azure Web App - cs4353

on:
push:
branches:
- main
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python version
uses: actions/setup-python@v1
with:
python-version: '3.12'

- name: Create and start virtual environment
run: |
python -m venv venv
source venv/bin/activate
- name: Install dependencies
run: pip install -r requirements.txt

# Optional: Add step to run tests here (PyTest, Django test suites, etc.)

- name: Zip artifact for deployment
run: zip release.zip ./* -r

- name: Upload artifact for deployment jobs
uses: actions/upload-artifact@v3
with:
name: python-app
path: |
release.zip
!venv/
deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: 'Production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
permissions:
id-token: write #This is required for requesting the JWT

steps:
- name: Download artifact from build job
uses: actions/download-artifact@v3
with:
name: python-app

- name: Unzip artifact for deployment
run: unzip release.zip


- name: Login to Azure
uses: azure/login@v1
with:
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_FB22A9DED53143DF908F44F27FDB42E6 }}
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_71C2FE5637E34A2BA2743390E861924B }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_C9C891EC5D1A4F198E7EA2D4BC41151F }}

- name: 'Deploy to Azure Web App'
uses: azure/webapps-deploy@v2
id: deploy-to-webapp
with:
app-name: 'cs4353'
slot-name: 'Production'

18 changes: 9 additions & 9 deletions backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,24 @@
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-rhl0ur6pohr@*2phgmo83%6m@cygd$2$8$-xkcr_md&@z@=&@9'
SECRET_KEY = os.getenv('SECRET_KEY')
# os.getenv('SECRET_KEY')


# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
DEBUG = os.getenv('DEBUG', '0').lower() in ['true', 't', '1']
# os.getenv('DEBUG', '0').lower() in ['true', 't', '1']
# True

ALLOWED_HOSTS = []
ALLOWED_HOSTS = os.getenv('ALLOWED_HOSTS').split(' ')
# os.getenv('ALLOWED_HOSTS').split(' ')

# These are for Azure deployment.
#CSRF_TRUSTED_ORIGINS = os.getenv('CSRF_TRUSTED_ORIGINS').split(' ')
CSRF_TRUSTED_ORIGINS = os.getenv('CSRF_TRUSTED_ORIGINS').split(' ')

#SECURE_SSL_REDIRECT = os.getenv('SECURE_SSL_REDIRECT', '0').lower() in ['true', 't', '1']
#if SECURE_SSL_REDIRECT:
#SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
SECURE_SSL_REDIRECT = os.getenv('SECURE_SSL_REDIRECT', '0').lower() in ['true', 't', '1']
if SECURE_SSL_REDIRECT:
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
Expand All @@ -60,10 +60,10 @@
'PORT': os.environ.get('DBPORT'),
'OPTIONS': {'sslmode': 'require'},
}
}
}"""
database_url = os.environ.get('DATABASE_URL')
DATABASES["default"] = dj_database_url.parse(database_url)
#os.environ.get('DATABASE_URL')"""
#os.environ.get('DATABASE_URL')

# Application definition

Expand Down
12 changes: 12 additions & 0 deletions frontend/public/staticwebapp.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"navigationFallback": {
"rewrite": "index.html",
"exclude": [
"/static/media/*.{png,jpg,jpeg,gif,bmp}",
"/static/css/*"
]
},
"mimeTypes": {
".json": "text/json"
}
}

0 comments on commit d85b3d7

Please sign in to comment.