Add GitHub workflows for deployment #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy FastAPI to Azure Functions | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Install Azure CLI | |
run: | | |
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash | |
- name: Log in to Azure | |
run: az login --service-principal -u ${{ secrets.AZURE_CREDENTIALS }} | |
- name: Deploy to Azure Functions | |
run: | | |
az functionapp deployment source config-zip \ | |
--resource-group <your-resource-group> \ | |
--name ${{ secrets.AZURE_FUNCTIONAPP_NAME }} \ | |
--src function_app.zip | |
env: | |
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }} | |
- name: Clean up | |
run: | | |
rm function_app.zip |