Skip to content

Commit

Permalink
add: deployment to UAT
Browse files Browse the repository at this point in the history
  • Loading branch information
alguadam committed Oct 8, 2023
1 parent be75b09 commit 06fb9bf
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 7 deletions.
32 changes: 30 additions & 2 deletions .github/workflows/ie-bank-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ permissions:

env:
BACKEND_WEBAPP_DEV: aguadamillas-be-dev
BACKEND_WEBAPP_UAT: aguadamillas-be-uat
source_branch_name: ${{ github.ref }}
pr_target_branch_name: ${{ github.base_ref }}

jobs:
build:
Expand Down Expand Up @@ -49,7 +52,7 @@ jobs:
path: |
.
deploy:
deploy-dev:
runs-on: ubuntu-latest
needs: build
environment:
Expand All @@ -73,4 +76,29 @@ jobs:
with:
app-name: ${{ env.BACKEND_WEBAPP_DEV }}
package: .


deploy-uat:
runs-on: ubuntu-latest
needs: [build, deploy-dev]
# if: ${{ pr_target_branch_name == 'refs/heads/main' }} #deploys only on PR to main branch
environment:
name: 'User Acceptance Testing'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

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

- uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- name: 'Deploy to Azure Web App'
uses: azure/webapps-deploy@v2
id: deploy-to-webapp
with:
app-name: ${{ env.BACKEND_WEBAPP_UAT }}
package: .
11 changes: 10 additions & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,13 @@ class DevelopmentConfig(Config):
dbhost=os.getenv('DBHOST'),
dbname=os.getenv('DBNAME')
)
DEBUG = True
DEBUG = True

class UATConfig(Config):
SQLALCHEMY_DATABASE_URI = 'postgresql://{dbuser}:{dbpass}@{dbhost}/{dbname}'.format(
dbuser=os.getenv('DBUSER'),
dbpass=os.getenv('DBPASS'),
dbhost=os.getenv('DBHOST'),
dbname=os.getenv('DBNAME')
)
DEBUG = False
8 changes: 4 additions & 4 deletions iebank_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
elif os.getenv('ENV') == 'ghci':
print("Running in github mode")
app.config.from_object('config.GithubCIConfig')
else:
print("Running in production mode")
app.config.from_object('config.ProductionConfig')
elif os.getenv('ENV') == 'uat':
print("Running in UAT mode")
app.config.from_object('config.UATConfig')

db = SQLAlchemy(app)

Expand All @@ -34,7 +34,7 @@
from iebank_api import routes

# Initialize Application Insights and force flushing application insights handler after each request
if(os.getenv('ENV') == 'dev'):
if(os.getenv('ENV') == 'dev' or os.getenv('ENV') == 'uat'):
appinsights = AppInsights(app)
@app.after_request
def after_request(response):
Expand Down

0 comments on commit 06fb9bf

Please sign in to comment.