1+ # Docs for the Azure Web Apps Deploy action: https://github.com/azure/functions-action
2+ # More GitHub Actions for Azure: https://github.com/Azure/actions
3+ # More info on Python, GitHub Actions, and Azure Functions: https://aka.ms/python-webapps-actions
4+
5+ name : Build and deploy Python project to Azure Function App - hvalfangstlinuxfunctionapp
6+
7+ on :
8+ push :
9+ branches :
10+ - main
11+ workflow_dispatch :
12+
13+ env :
14+ AZURE_FUNCTIONAPP_PACKAGE_PATH : ' .' # set this to the path to your web app project, defaults to the repository root
15+ PYTHON_VERSION : ' 3.11' # set this to the python version to use (supports 3.6, 3.7, 3.8)
16+
17+ jobs :
18+ build :
19+ runs-on : ubuntu-latest
20+ steps :
21+ - name : Checkout repository
22+ uses : actions/checkout@v4
23+
24+ - name : Setup Python version
25+ uses : actions/setup-python@v5
26+ with :
27+ python-version : ${{ env.PYTHON_VERSION }}
28+
29+ - name : Create and start virtual environment
30+ run : |
31+ python -m venv venv
32+ source venv/bin/activate
33+
34+ - name : Install dependencies
35+ run : pip install -r requirements.txt
36+
37+ # Optional: Add step to run tests here
38+
39+ - name : Zip artifact for deployment
40+ run : zip release.zip ./* -r
41+
42+ - name : Upload artifact for deployment job
43+ uses : actions/upload-artifact@v4
44+ with :
45+ name : python-app
46+ path : |
47+ release.zip
48+ !venv/
49+
50+ deploy :
51+ runs-on : ubuntu-latest
52+ needs : build
53+
54+ permissions :
55+ id-token : write # This is required for requesting the JWT
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 : Unzip artifact for deployment
64+ run : unzip release.zip
65+
66+ - name : Login to Azure
67+ uses : azure/login@v2
68+ with :
69+ client-id : ${{ secrets.AZUREAPPSERVICE_CLIENTID_45F263BF4662456FA6CAF9777649A827 }}
70+ tenant-id : ${{ secrets.AZUREAPPSERVICE_TENANTID_2F6C4F2E4B114D4591C460D73A3AAE41 }}
71+ subscription-id : ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_074AC658FD334500AEB5203E919D5F8B }}
72+
73+ - name : ' Deploy to Azure Functions'
74+ uses : Azure/functions-action@v1
75+ id : deploy-to-function
76+ with :
77+ app-name : ' hvalfangstlinuxfunctionapp'
78+ slot-name : ' Production'
79+ package : ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
80+
0 commit comments