Skip to content

Commit af4ab11

Browse files
committed
hoping this copy paste
1 parent 4b9256a commit af4ab11

File tree

1 file changed

+48
-57
lines changed

1 file changed

+48
-57
lines changed
+48-57
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,72 @@
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
43

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

76
on:
87
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
1213

1314
jobs:
14-
build:
15+
build-and-test:
1516
runs-on: ubuntu-latest
16-
17+
1718
steps:
18-
- uses: actions/checkout@v4
19+
- uses: actions/checkout@v2
1920

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
2425

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
3030
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
3533

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

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
5050
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
5751

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

68-
- name: Login to Azure
58+
- name: Log in to Azure CLI
6959
uses: azure/login@v1
7060
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"}]'
7468

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

0 commit comments

Comments
 (0)