Skip to content

Commit 7acab3a

Browse files
committed
back to old strat
1 parent ee3762f commit 7acab3a

File tree

1 file changed

+55
-50
lines changed

1 file changed

+55
-50
lines changed
+55-50
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,80 @@
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
34

4-
name: Build and deploy Django app to Azure App Service
5+
name: Build and deploy Python app to Azure Web App - BackendBlueNPS
56

67
on:
78
push:
8-
branches:
9+
branches:
910
- main
10-
11-
env:
12-
WEBAPP_NAME: 'bluenpsbackend' # Replace with the name of your Azure web app
11+
workflow_dispatch:
1312

1413
jobs:
15-
build-and-test:
14+
build:
1615
runs-on: ubuntu-latest
17-
defaults:
18-
run:
19-
working-directory:
20-
./bluenpsbackend
16+
2117
steps:
22-
- uses: actions/checkout@v2
18+
- uses: actions/checkout@v4
2319

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'
2824

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
3330
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+
3635

37-
- name: Collect static
38-
run: python manage.py collectstatic
36+
# Optional: Add step to run tests here (PyTest, Django test suites, etc.)
3937

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:
5350
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
5457

5558
steps:
56-
- uses: actions/download-artifact@v2
59+
- name: Download artifact from build job
60+
uses: actions/download-artifact@v3
5761
with:
5862
name: python-app
59-
path: .
63+
64+
- name: Unzip artifact for deployment
65+
run: unzip release.zip
66+
6067

61-
- name: Log in to Azure CLI
68+
- name: Login to Azure
6269
uses: azure/login@v1
6370
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 }}
7174

72-
- name: Deploy to App Service
75+
- name: 'Deploy to Azure Web App'
7376
uses: azure/webapps-deploy@v2
77+
id: deploy-to-webapp
7478
with:
75-
app-name: ${{ env.WEBAPP_NAME}}
79+
app-name: 'BackendBlueNPS'
80+
slot-name: 'Production'

0 commit comments

Comments
 (0)