Skip to content

Commit b6a3711

Browse files
committed
2 parents 798cb7f + 357ec48 commit b6a3711

File tree

3 files changed

+155
-0
lines changed

3 files changed

+155
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
4+
name: Build and deploy Python app to Azure Web App - screencast20
5+
6+
on:
7+
push:
8+
branches:
9+
- master
10+
11+
jobs:
12+
build-and-deploy:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@master
17+
18+
- name: Set up Python version
19+
uses: actions/setup-python@v1
20+
with:
21+
python-version: '3.8'
22+
23+
- name: Build using AppService-Build
24+
uses: azure/appservice-build@v1
25+
with:
26+
platform: python
27+
platform-version: '3.8'
28+
29+
- name: 'Deploy to Azure Web App'
30+
uses: azure/webapps-deploy@v1
31+
with:
32+
app-name: 'screencast20'
33+
slot-name: 'production'
34+
publish-profile: ${{ secrets.AzureAppService_PublishProfile_b928012312c44f82b061fb204f14d5bb }}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
4+
name: Build and deploy Python app to Azure Web App - screencast2020
5+
6+
on:
7+
push:
8+
branches:
9+
- master
10+
11+
jobs:
12+
build-and-deploy:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@master
17+
18+
- name: Set up Python version
19+
uses: actions/setup-python@v1
20+
with:
21+
python-version: '3.7'
22+
23+
- name: Build using AppService-Build
24+
uses: azure/appservice-build@v1
25+
with:
26+
platform: python
27+
platform-version: '3.7'
28+
29+
- name: 'Deploy to Azure Web App'
30+
uses: azure/webapps-deploy@v1
31+
with:
32+
app-name: 'screencast2020'
33+
slot-name: 'production'
34+
publish-profile: ${{ secrets.AzureAppService_PublishProfile_65a6ac3231434072974950530979eb22 }}

azure-pipelines.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Python to Linux Web App on Azure
2+
# Build your Python project and deploy it to Azure as a Linux Web App.
3+
# Change python version to one thats appropriate for your application.
4+
# https://docs.microsoft.com/azure/devops/pipelines/languages/python
5+
6+
trigger:
7+
- master
8+
9+
variables:
10+
# Azure Resource Manager connection created during pipeline creation
11+
azureServiceConnectionId: '2e1aa168-a94a-470f-a8b6-7c96d2c35fbf'
12+
13+
# Web app name
14+
webAppName: 'screencast20'
15+
16+
# Agent VM image name
17+
vmImageName: 'ubuntu-latest'
18+
19+
# Environment name
20+
environmentName: 'screencast20'
21+
22+
# Project root folder. Point to the folder containing manage.py file.
23+
projectRoot: $(System.DefaultWorkingDirectory)
24+
25+
# Python version: 3.7
26+
pythonVersion: '3.7'
27+
28+
stages:
29+
- stage: Build
30+
displayName: Build stage
31+
jobs:
32+
- job: BuildJob
33+
pool:
34+
vmImage: $(vmImageName)
35+
steps:
36+
- task: UsePythonVersion@0
37+
inputs:
38+
versionSpec: '$(pythonVersion)'
39+
displayName: 'Use Python $(pythonVersion)'
40+
41+
- script: |
42+
python -m venv antenv
43+
source antenv/bin/activate
44+
python -m pip install --upgrade pip
45+
pip install setup
46+
pip install -r requirements.txt
47+
workingDirectory: $(projectRoot)
48+
displayName: "Install requirements"
49+
50+
- task: ArchiveFiles@2
51+
displayName: 'Archive files'
52+
inputs:
53+
rootFolderOrFile: '$(projectRoot)'
54+
includeRootFolder: false
55+
archiveType: zip
56+
archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
57+
replaceExistingArchive: true
58+
59+
- upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
60+
displayName: 'Upload package'
61+
artifact: drop
62+
63+
- stage: Deploy
64+
displayName: 'Deploy Web App'
65+
dependsOn: Build
66+
condition: succeeded()
67+
jobs:
68+
- deployment: DeploymentJob
69+
pool:
70+
vmImage: $(vmImageName)
71+
environment: $(environmentName)
72+
strategy:
73+
runOnce:
74+
deploy:
75+
steps:
76+
77+
- task: UsePythonVersion@0
78+
inputs:
79+
versionSpec: '$(pythonVersion)'
80+
displayName: 'Use Python version'
81+
82+
- task: AzureWebApp@1
83+
displayName: 'Deploy Azure Web App : screencast20'
84+
inputs:
85+
azureSubscription: $(azureServiceConnectionId)
86+
appName: $(webAppName)
87+
package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip

0 commit comments

Comments
 (0)