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 - discord-bday-python-bot
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.12' # 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+ permissions :
21+ contents : read # This is required for actions/checkout
22+
23+ steps :
24+ - name : Checkout repository
25+ uses : actions/checkout@v4
26+
27+ - name : Setup Python version
28+ uses : actions/setup-python@v5
29+ with :
30+ python-version : ${{ env.PYTHON_VERSION }}
31+
32+ - name : Create and start virtual environment
33+ run : |
34+ python -m venv venv
35+ source venv/bin/activate
36+
37+ - name : Install dependencies
38+ run : pip install -r requirements.txt
39+
40+ # Optional: Add step to run tests here
41+
42+ - name : Zip artifact for deployment
43+ run : zip release.zip ./* -r
44+
45+ - name : Upload artifact for deployment job
46+ uses : actions/upload-artifact@v4
47+ with :
48+ name : python-app
49+ path : |
50+ release.zip
51+ !venv/
52+
53+ deploy :
54+ runs-on : ubuntu-latest
55+ needs : build
56+ permissions :
57+ id-token : write # This is required for requesting the JWT
58+ contents : read # This is required for actions/checkout
59+
60+ steps :
61+ - name : Download artifact from build job
62+ uses : actions/download-artifact@v4
63+ with :
64+ name : python-app
65+
66+ - name : Unzip artifact for deployment
67+ run : unzip release.zip
68+
69+ - name : Login to Azure
70+ uses : azure/login@v2
71+ with :
72+ client-id : ${{ secrets.AZUREAPPSERVICE_CLIENTID_D4DA2DFADD11440B8D9DD4CB55E83554 }}
73+ tenant-id : ${{ secrets.AZUREAPPSERVICE_TENANTID_349FE29549994288AE097512AB7A7BBA }}
74+ subscription-id : ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_3265547455634577AAFF8277D0F46E2A }}
75+
76+ - name : ' Deploy to Azure Functions'
77+ uses : Azure/functions-action@v1
78+ id : deploy-to-function
79+ with :
80+ app-name : ' discord-bday-python-bot'
81+ slot-name : ' Production'
82+ package : ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
83+
0 commit comments