Skip to content

Commit

Permalink
Create azure-webapps-python.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
akshata29 authored Feb 3, 2024
1 parent 16832e0 commit 51c7491
Showing 1 changed file with 110 additions and 0 deletions.
110 changes: 110 additions & 0 deletions .github/workflows/azure-webapps-python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# This workflow will build and push a Python application to an Azure Web App when a commit is pushed to your default branch.
#
# This workflow assumes you have already created the target Azure App Service web app.
# For instructions see https://docs.microsoft.com/en-us/azure/app-service/quickstart-python?tabs=bash&pivots=python-framework-flask
#
# To configure this workflow:
#
# 1. Download the Publish Profile for your Azure Web App. You can download this file from the Overview page of your Web App in the Azure Portal.
# For more information: https://docs.microsoft.com/en-us/azure/app-service/deploy-github-actions?tabs=applevel#generate-deployment-credentials
#
# 2. Create a secret in your repository named AZURE_WEBAPP_PUBLISH_PROFILE, paste the publish profile contents as the value of the secret.
# For instructions on obtaining the publish profile see: https://docs.microsoft.com/azure/app-service/deploy-github-actions#configure-the-github-secret
#
# 3. Change the value for the AZURE_WEBAPP_NAME. Optionally, change the PYTHON_VERSION environment variables below.
#
# For more information on GitHub Actions for Azure: https://github.com/Azure/Actions
# For more information on the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# For more samples to get started with GitHub Action workflows to deploy to Azure: https://github.com/Azure/actions-workflow-samples

name: Deploy Pitchbook App

env:
AZURE_WEBAPP_NAME: pitchbookfsi # set this to the name of your Azure Web App
PYTHON_VERSION: '3.11' # set this to the Python version to use
NODE_VERSION: '16.x' # set this to the node version to use (e.g. '8.x', '10.x', '12.x')
AZURE_NODEJS_PACKAGE_PATH: 'app/frontend' # set this to the path to your function app project, defaults to the repository root
AZURE_FUNCTIONAPP_PACKAGE_PATH: 'app/backend'

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

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Setup Node ${{ env.NODE_VERSION }} Environment
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}

- name: 'Resolve Project Dependencies Using Npm'
shell: bash # For Linux, use bash
run: |
pushd './${{ env.AZURE_NODEJS_PACKAGE_PATH }}'
export NODE_OPTIONS="--max_old_space_size=4096"
npm install
npm run build
popd
- name: Set up Python version
uses: actions/[email protected]
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip'

- name: Create and start virtual environment
run: |
python -m venv venv
source venv/bin/activate
- name: 'Resolve Project Dependencies Using Pip'
shell: bash
run: |
pushd './${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}'
python -m pip install --upgrade pip
pip install -r requirements.txt
popd
# Optional: Add step to run tests here (PyTest, Django test suites, etc.)

- name: Upload artifact for deployment jobs
uses: actions/upload-artifact@v3
with:
name: python-app
path: |
./${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
!venv/
deploy:
permissions:
contents: none
runs-on: ubuntu-latest
needs: build
environment:
name: 'Development'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

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

- name: 'Deploy to Azure Web App'
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }}
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
scm-do-build-during-deployment: true
enable-oryx-build: true

0 comments on commit 51c7491

Please sign in to comment.