1
- # Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
2
- # More GitHub Actions for Azure: https://github.com/Azure/actions
3
- # More info on Python, GitHub Actions, and Azure App Service: https://aka.ms/python-webapps-actions
1
+ # For more info on Python, GitHub Actions, and Azure App Service
2
+ # please head to https://aka.ms/python-webapps-actions
4
3
5
- name : Build and deploy Python app to Azure Web App - BackendBlueNPS
4
+ name : Build and deploy Django app to Azure App Service
6
5
7
6
on :
8
7
push :
9
- branches :
10
- - main
11
- workflow_dispatch :
8
+ branches :
9
+ - master
10
+
11
+ env :
12
+ WEBAPP_NAME : ' my-python-app' # Replace with the name of your Azure web app
12
13
13
14
jobs :
14
- build :
15
+ build-and-test :
15
16
runs-on : ubuntu-latest
16
-
17
+
17
18
steps :
18
- - uses : actions/checkout@v4
19
+ - uses : actions/checkout@v2
19
20
20
- - name : Set up Python version
21
- uses : actions/setup-python@v1
22
- with :
23
- python-version : ' 3.12 '
21
+ - name : Setup Python version
22
+ uses : actions/setup-python@v2
23
+ with :
24
+ python-version : 3.8
24
25
25
- - name : Create and start virtual environment
26
- working-directory : ./bluenpsbackend
27
- run : |
28
- python -m venv venv
29
- source venv/bin/activate
26
+ - name : Create and start virtual environment
27
+ run : |
28
+ python3 -m venv venv
29
+ source venv/bin/activate
30
30
31
- # I added this and I hope its good
32
- - name : Collect static
33
- run : python manage.py collectstatic
34
-
31
+ - name : Install dependencies
32
+ run : pip install -r requirements.txt
35
33
36
- # Optional: Add step to run tests here (PyTest, Django test suites, etc.)
34
+ - name : Collect static
35
+ run : python manage.py collectstatic
37
36
38
- - name : Zip artifact for deployment
39
- run : zip release.zip ./* -r
40
-
41
- - name : Upload artifact for deployment jobs
42
- uses : actions/upload-artifact@v3
43
- with :
44
- name : python-app
45
- path : |
46
- release.zip
47
- !venv/
48
-
49
- deploy :
37
+ - name : Run tests
38
+ run : python manage.py test
39
+
40
+ - name : Upload artifact for deployment jobs
41
+ uses : actions/upload-artifact@v2
42
+ with :
43
+ name : python-app
44
+ path : |
45
+ .
46
+ !venv/
47
+
48
+ deploy-to-webapp :
49
+ needs : build-and-test
50
50
runs-on : ubuntu-latest
51
- needs : build
52
- environment :
53
- name : ' Production'
54
- url : ${{ steps.deploy-to-webapp.outputs.webapp-url }}
55
- permissions :
56
- id-token : write # This is required for requesting the JWT
57
51
58
52
steps :
59
- - name : Download artifact from build job
60
- uses : actions/download-artifact@v3
53
+ - uses : actions/download-artifact@v2
61
54
with :
62
55
name : python-app
63
-
64
- - name : Unzip artifact for deployment
65
- run : unzip release.zip
66
-
56
+ path : .
67
57
68
- - name : Login to Azure
58
+ - name : Log in to Azure CLI
69
59
uses : azure/login@v1
70
60
with :
71
- client-id : ${{ secrets.AZUREAPPSERVICE_CLIENTID_5D5BE84F72B6418DA3021095978ABD20 }}
72
- tenant-id : ${{ secrets.AZUREAPPSERVICE_TENANTID_B3EE49EEC1084718B0A446AAACDE3BE8 }}
73
- subscription-id : ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_0FD85ED14F714A3091FF152944D5BD8A }}
61
+ creds : ${{ secrets.AZURE_SERVICE_PRINCIPAL }}
62
+
63
+ - name : Disable static collection and set migration command on App Service
64
+ uses : Azure/appservice-settings@v1
65
+ with :
66
+ app-name : ${{ env.WEBAPP_NAME }}
67
+ app-settings-json : ' [{ "name": "DISABLE_COLLECTSTATIC", "value": "true" }, { "name": "POST_BUILD_COMMAND", "value": "python manage.py makemigrations && python manage.py migrate" }, { "name": "SCM_DO_BUILD_DURING_DEPLOYMENT", "value": "true" }, { "name": "DJANGO_ENV", "value": "production"}]'
74
68
75
- - name : ' Deploy to Azure Web App'
69
+ - name : Deploy to App Service
76
70
uses : azure/webapps-deploy@v2
77
- id : deploy-to-webapp
78
71
with :
79
- app-name : ' BackendBlueNPS'
80
- slot-name : ' Production'
81
-
72
+ app-name : ${{ env.WEBAPP_NAME}}
0 commit comments