|
| 1 | +# This workflow will build and push a Python application to an Azure Web App when a commit is pushed to your default branch. |
| 2 | +# |
| 3 | +# This workflow assumes you have already created the target Azure App Service web app. |
| 4 | +# For instructions see https://docs.microsoft.com/en-us/azure/app-service/quickstart-python?tabs=bash&pivots=python-framework-flask |
| 5 | +# |
| 6 | +# To configure this workflow: |
| 7 | +# |
| 8 | +# 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. |
| 9 | +# For more information: https://docs.microsoft.com/en-us/azure/app-service/deploy-github-actions?tabs=applevel#generate-deployment-credentials |
| 10 | +# |
| 11 | +# 2. Create a secret in your repository named AZURE_WEBAPP_PUBLISH_PROFILE, paste the publish profile contents as the value of the secret. |
| 12 | +# For instructions on obtaining the publish profile see: https://docs.microsoft.com/azure/app-service/deploy-github-actions#configure-the-github-secret |
| 13 | +# |
| 14 | +# 3. Change the value for the AZURE_WEBAPP_NAME. Optionally, change the PYTHON_VERSION environment variables below. |
| 15 | +# |
| 16 | +# For more information on GitHub Actions for Azure: https://github.com/Azure/Actions |
| 17 | +# For more information on the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy |
| 18 | +# For more samples to get started with GitHub Action workflows to deploy to Azure: https://github.com/Azure/actions-workflow-samples |
| 19 | + |
| 20 | +name: Deploy Pitchbook App |
| 21 | + |
| 22 | +env: |
| 23 | + AZURE_WEBAPP_NAME: pitchbookfsi # set this to the name of your Azure Web App |
| 24 | + PYTHON_VERSION: '3.11' # set this to the Python version to use |
| 25 | + NODE_VERSION: '16.x' # set this to the node version to use (e.g. '8.x', '10.x', '12.x') |
| 26 | + AZURE_NODEJS_PACKAGE_PATH: 'app/frontend' # set this to the path to your function app project, defaults to the repository root |
| 27 | + AZURE_FUNCTIONAPP_PACKAGE_PATH: 'app/backend' |
| 28 | + |
| 29 | +on: |
| 30 | + push: |
| 31 | + branches: [ "main" ] |
| 32 | + workflow_dispatch: |
| 33 | + |
| 34 | +permissions: |
| 35 | + contents: read |
| 36 | + |
| 37 | +jobs: |
| 38 | + build: |
| 39 | + runs-on: ubuntu-latest |
| 40 | + |
| 41 | + steps: |
| 42 | + - uses: actions/checkout@v3 |
| 43 | + |
| 44 | + - name: Setup Node ${{ env.NODE_VERSION }} Environment |
| 45 | + uses: actions/setup-node@v3 |
| 46 | + with: |
| 47 | + node-version: ${{ env.NODE_VERSION }} |
| 48 | + |
| 49 | + - name: 'Resolve Project Dependencies Using Npm' |
| 50 | + shell: bash # For Linux, use bash |
| 51 | + run: | |
| 52 | + pushd './${{ env.AZURE_NODEJS_PACKAGE_PATH }}' |
| 53 | + export NODE_OPTIONS="--max_old_space_size=4096" |
| 54 | + npm install |
| 55 | + npm run build |
| 56 | + popd |
| 57 | + |
| 58 | + - name: Set up Python version |
| 59 | + uses: actions/setup-python@v3.0.0 |
| 60 | + with: |
| 61 | + python-version: ${{ env.PYTHON_VERSION }} |
| 62 | + cache: 'pip' |
| 63 | + |
| 64 | + - name: Create and start virtual environment |
| 65 | + run: | |
| 66 | + python -m venv venv |
| 67 | + source venv/bin/activate |
| 68 | +
|
| 69 | + - name: 'Resolve Project Dependencies Using Pip' |
| 70 | + shell: bash |
| 71 | + run: | |
| 72 | + pushd './${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}' |
| 73 | + python -m pip install --upgrade pip |
| 74 | + pip install -r requirements.txt |
| 75 | + popd |
| 76 | +
|
| 77 | + # Optional: Add step to run tests here (PyTest, Django test suites, etc.) |
| 78 | + |
| 79 | + - name: Upload artifact for deployment jobs |
| 80 | + uses: actions/upload-artifact@v3 |
| 81 | + with: |
| 82 | + name: python-app |
| 83 | + path: | |
| 84 | + ./${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }} |
| 85 | + !venv/ |
| 86 | +
|
| 87 | + deploy: |
| 88 | + permissions: |
| 89 | + contents: none |
| 90 | + runs-on: ubuntu-latest |
| 91 | + needs: build |
| 92 | + environment: |
| 93 | + name: 'Development' |
| 94 | + url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} |
| 95 | + |
| 96 | + steps: |
| 97 | + - name: Download artifact from build job |
| 98 | + uses: actions/download-artifact@v3 |
| 99 | + with: |
| 100 | + name: python-app |
| 101 | + path: . |
| 102 | + |
| 103 | + - name: 'Deploy to Azure Web App' |
| 104 | + id: deploy-to-webapp |
| 105 | + uses: azure/webapps-deploy@v2 |
| 106 | + with: |
| 107 | + app-name: ${{ env.AZURE_WEBAPP_NAME }} |
| 108 | + publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} |
| 109 | + scm-do-build-during-deployment: true |
| 110 | + enable-oryx-build: true |
0 commit comments