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