-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (71 loc) · 2.41 KB
/
main_hodlbot-api.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: Deploy FastAPI Backend to Azure
on:
push:
branches:
- main
paths:
- '**/*' # Trigger on changes anywhere
workflow_dispatch: # Allows manual triggering from GitHub Actions UI
jobs:
backend-deploy:
name: Deploy FastAPI Backend
runs-on: ubuntu-latest
steps:
# Step 1: Checkout Code
- name: Checkout Code
uses: actions/checkout@v3
# Step 2: Verify Checkout
- name: Verify Checkout
run: ls -la || exit 1
# Step 3: Log in to Azure
- name: Log in to Azure
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
# Step 4: Verify Azure Login
- name: Verify Azure Login
run: az account show || exit 1
# Step 5: Set up Python
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
# Step 6: Verify Python Setup
- name: Verify Python Setup
run: python --version || exit 1
# Step 7: Install Dependencies
- name: Install Dependencies
run: |
python -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
echo "✅ Dependencies installed"
# Step 8: Verify Dependencies Installation
- name: Verify Dependencies Installation
run: |
source .venv/bin/activate
pip list || exit 1
# Step 9: Set SCM_DO_BUILD_DURING_DEPLOYMENT
- name: Disable Oryx Build
run: |
echo "SCM_DO_BUILD_DURING_DEPLOYMENT=false" > .env
# Step 10: Create a ZIP Package
- name: ZIP the Application
run: |
zip -r backend.zip . -x "*.git*" "*.venv/*" "__pycache__/*" "*.DS_Store"
# Step 11: Verify ZIP File Creation
- name: Verify ZIP File Creation
run: ls -lh backend.zip || exit 1
# Step 12: Deploy to Azure App Service
- name: Deploy FastAPI Backend to Azure App Service
uses: azure/webapps-deploy@v2
with:
app-name: "hodlbot-api"
package: "backend.zip"
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
# Step 13: Verify Deployment with a Test Request
- name: Verify Deployment
run: |
sleep 10 # Wait for deployment to complete
curl -f https://hodlbot-api-bmcmdhccf5hmgahy.eastus2-01.azurewebsites.net || exit 1