-
Notifications
You must be signed in to change notification settings - Fork 628
/
python-webapp-on-azure.yml
60 lines (59 loc) · 2.13 KB
/
python-webapp-on-azure.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Python on Linux Web App
# Build a Python project (using Django/Flask/Bottle frameworks) and deploy it to Azure as a Linux web app.
name: Deploy Python package to Azure Web App as a Linux web app.
on:
[push]
# CONFIGURATION
# For help, go to https://github.com/Azure/Actions
# See this in-depth article on CI for Python applications: https://azure.github.io/AppService/2020/12/11/cicd-for-python-apps.html
#
# 1. Set up the following secrets in your repository:
# AZURE_CREDENTIALS_GITHUB_SECRET
#
# 2. Change these variables for your configuration:
env:
AZURE_WEBAPP_NAME: my-app # set this to your application's name
WORKING_DIRECTORY: '.' # set this to the path to your path of working directory inside github repository, defaults to the repository root
PYTHON_VERSION: '3.10' # set the version to use
STARTUP_COMMAND: '' # set this to the startup command required to start the gunicorn server. default it is empty
name: Build and deploy Python app
jobs:
build-and-deploy:
runs-on: ubuntu-latest
environment: dev
steps:
# checkout the repo
- uses: actions/checkout@v3
# setup python
- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: ${{ env.PYTHON_VERSION }}
# install dependencies
- name: python install
working-directory: ${{ env.WORKING_DIRECTORY }}
run: |
sudo apt install python${{ env.PYTHON_VERSION }}-venv
python -m venv --copies antenv
source antenv/bin/activate
pip install setuptools
pip install -r requirements.txt
# Azure login
- uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS_GITHUB_SECRET }}
- uses: azure/appservice-settings@v1
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }}
mask-inputs: false
general-settings-json: '{"linuxFxVersion": "PYTHON|${{ env.PYTHON_VERSION }}"}' #'General configuration settings as Key Value pairs'
# deploy web app
- uses: azure/webapps-deploy@v2
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }}
package: ${{ env.WORKING_DIRECTORY }}
startup-command: ${{ env.STARTUP_COMMAND }}
# Azure logout
- name: logout
run: |
az logout