Skip to content

Commit 7bd2bec

Browse files
committed
Add or update the Azure App Service build and deployment workflow config
1 parent 62232a3 commit 7bd2bec

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
2+
# More GitHub Actions for Azure: https://github.com/Azure/actions
3+
# More info on Python, GitHub Actions, and Azure App Service: https://aka.ms/python-webapps-actions
4+
5+
name: Build and deploy Python app to Azure Web App - testwebappforgithub
6+
7+
on:
8+
push:
9+
branches:
10+
- main
11+
workflow_dispatch:
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read #This is required for actions/checkout
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Set up Python version
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: '3.13'
26+
27+
# 🛠️ Local Build Section (Optional)
28+
# The following section in your workflow is designed to catch build issues early on the client side, before deployment. This can be helpful for debugging and validation. However, if this step significantly increases deployment time and early detection is not critical for your workflow, you may remove this section to streamline the deployment process.
29+
- name: Create and Start virtual environment and Install dependencies
30+
run: |
31+
python -m venv antenv
32+
source antenv/bin/activate
33+
pip install -r requirements.txt
34+
35+
# By default, when you enable GitHub CI/CD integration through the Azure portal, the platform automatically sets the SCM_DO_BUILD_DURING_DEPLOYMENT application setting to true. This triggers the use of Oryx, a build engine that handles application compilation and dependency installation (e.g., pip install) directly on the platform during deployment. Hence, we exclude the antenv virtual environment directory from the deployment artifact to reduce the payload size.
36+
- name: Upload artifact for deployment jobs
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: python-app
40+
path: |
41+
.
42+
!antenv/
43+
44+
# 🚫 Opting Out of Oryx Build
45+
# If you prefer to disable the Oryx build process during deployment, follow these steps:
46+
# 1. Remove the SCM_DO_BUILD_DURING_DEPLOYMENT app setting from your Azure App Service Environment variables.
47+
# 2. Refer to sample workflows for alternative deployment strategies: https://github.com/Azure/actions-workflow-samples/tree/master/AppService
48+
49+
50+
deploy:
51+
runs-on: ubuntu-latest
52+
needs: build
53+
permissions:
54+
id-token: write #This is required for requesting the JWT
55+
contents: read #This is required for actions/checkout
56+
57+
steps:
58+
- name: Download artifact from build job
59+
uses: actions/download-artifact@v4
60+
with:
61+
name: python-app
62+
63+
- name: Login to Azure
64+
uses: azure/login@v2
65+
with:
66+
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_5B0D5BBEA8314C8E9B604CF2F105E9A2 }}
67+
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_35DBB40E0F874A108241DECFBF33D97E }}
68+
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_8875EA1ABC7E4D9B82414B9DBB9E6826 }}
69+
70+
- name: 'Deploy to Azure Web App'
71+
uses: azure/webapps-deploy@v3
72+
id: deploy-to-webapp
73+
with:
74+
app-name: 'testwebappforgithub'
75+
slot-name: 'Production'
76+

0 commit comments

Comments
 (0)