Pushed requirements.txt #3
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 Backend to Azure | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- '**/*' # Trigger on changes anywhere (or adjust as needed) | |
workflow_dispatch: # Allows manual triggering from GitHub Actions UI | |
jobs: | |
backend-deploy: | |
name: Deploy FastAPI Backend | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v2 | |
- name: Verify Checkout | |
run: ls -la || exit 1 | |
- name: Log in to Azure | |
uses: azure/login@v1 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} | |
- name: Verify Azure Login | |
run: az account show || exit 1 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Verify Python Setup | |
run: python --version || exit 1 | |
- name: Install Dependencies | |
run: | | |
python -m venv .venv | |
source .venv/bin/activate | |
pip install --upgrade pip | |
pip install -r requirements.txt | |
echo "✅ Dependencies installed" | |
- name: Verify Dependencies Installation | |
run: | | |
source .venv/bin/activate | |
pip list || exit 1 | |
- name: Oryx Opt Out | |
run: | | |
echo "SCM_DO_BUILD_DURING_DEPLOYMENT=false" >> .env | |
- name: ZIP the Application | |
run: | | |
# Zip the entire repository (excluding git files, the local venv, caches, etc.) | |
zip -r backend.zip . -x "*.git*" "*.venv/*" "__pycache__/*" "*.DS_Store" | |
- name: Verify ZIP File Creation | |
run: ls -lh backend.zip || exit 1 | |
- name: Deploy FastAPI Backend to Azure App Service | |
uses: azure/webapps-deploy@v2 | |
with: | |
app-name: "hodlbot-api" | |
slot-name: "production" | |
package: "backend.zip" | |
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} | |
- name: Verify Deployment | |
run: | | |
sleep 10 # Allow some time for deployment | |
curl -f hodlbot-api-bmcmdhccf5hmgahy.eastus2-01.azurewebsites.net || exit 1 |