Skip to content

Update azure-webapps-python.yml #36

Update azure-webapps-python.yml

Update azure-webapps-python.yml #36

name: Build and deploy Python app to Azure Web App
env:
AZURE_WEBAPP_NAME: diaweb # set this to your application's name
PYTHON_VERSION: '3.10' # set this to the Python version to use
on:
push:
branches:
- DIA
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python version
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Create virtual environment
run: python -m venv venv
- name: Activate virtual environment
run: source venv/bin/activate
- name: Set up dependency caching for faster installs
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: pip install -r requirements.txt
- name: Create artifact
run: |
mkdir -p ./build
cp -R * ./build/
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: python-app
path: ./build
# Optional: Add a step to run tests here (PyTest, Django test suites, etc.)
deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: 'production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download Artifact
uses: actions/download-artifact@v4
with:
name: python-app
- name: Build and deploy
run: |
oryx build /github/workspace --platform python --platform-version 3.10 > oryx-build.log
cat oryx-build.log
- name: Zip Artifact
run: zip -r diaweb.zip ./build
- name: 'Deploy to Azure Web App'
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }}
publish-profile: ${{ secrets.AZUREWEBAPPPUBLISHPROFILE }}
slot-name: production
package: diaweb.zip