Your YAML configuration has syntax issues due to the backticks (`) used instead of colons (:).
name: Build and deploy Python app to Azure Web App - Book-bag
on:
push:
branches:
- azure_deploy
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python version
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Create and start virtual environment
run: |
python -m venv venv
source venv/bin/activate
- name: Install dependencies
run: |
source venv/bin/activate
pip install -r requirements.txt
- name: Initialize database
run: |
source venv/bin/activate
cd BookBag/
flask db init
- name: Migrate database
run: |
source venv/bin/activate
cd BookBag/
flask db migrate
- name: Upgrade database
run: |
source venv/bin/activate
cd BookBag/
flask db upgrade
- name: Run tests
run: |
source venv/bin/activate
cd BookBag/
pytest
- name: Zip artifact for deployment
run: |
zip -r release.zip . -x "venv/*"
- name: Upload artifact for deployment jobs
uses: actions/upload-artifact@v4
with:
name: python-app
path: release.zip
deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: 'production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: python-app
- name: Unzip artifact for deployment
run: unzip release.zip
- name: 'Azure Login'
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: 'Deploy to Azure Web App'
uses: azure/webapps-deploy@v3
id: deploy-to-webapp
with:
app-name: 'Book-bag'
slot-name: 'production'
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
You might need to configure your Flask app to connect to the Azure SQL Database. Ensure you have the correct database connection settings in your config.py
or equivalent configuration file.
Review the deployment logs for specific errors. Some common issues include incorrect database configurations or missing dependencies.