Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
170 changes: 170 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
name: "Deploy Fine-Grained Demand Forecasting DAB"

on:
workflow_dispatch:
inputs:
environment:
description: 'Environment to deploy to'
required: true
default: 'dev'
type: choice
options:
- dev
- staging
- prod
push:
branches:
- main
- develop
pull_request:
branches:
- main

env:
DATABRICKS_HOST: ${{ secrets.DATABRICKS_HOST }}
DATABRICKS_TOKEN: ${{ secrets.DATABRICKS_TOKEN }}

jobs:
code-quality:
name: "Code Quality Checks"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -e src/

- name: Run linting
run: |
flake8 src/ --max-line-length=88 --extend-ignore=E203,W503
black --check src/

- name: Run type checking
run: |
mypy src/ --ignore-missing-imports

- name: Run unit tests
run: |
pytest tests/ -v --cov=demand_forecasting --cov-report=xml

- name: Upload coverage reports
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml

validate-bundle:
name: "Validate Databricks Bundle"
runs-on: ubuntu-latest
needs: code-quality
steps:
- uses: actions/checkout@v4

- name: Setup Databricks CLI
uses: databricks/setup-cli@main

- name: Validate bundle configuration
run: |
databricks bundle validate --target dev

- name: Generate bundle deployment plan
run: |
databricks bundle plan --target dev

deploy-dev:
name: "Deploy to Development"
runs-on: ubuntu-latest
needs: [code-quality, validate-bundle]
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/main'
environment: dev
steps:
- uses: actions/checkout@v4

- name: Setup Databricks CLI
uses: databricks/setup-cli@main

- name: Deploy to dev environment
run: |
databricks bundle deploy --target dev

- name: Run data generation pipeline
run: |
databricks bundle run demand_forecasting_pipeline --target dev

- name: Verify deployment
run: |
databricks bundle summary --target dev

deploy-staging:
name: "Deploy to Staging"
runs-on: ubuntu-latest
needs: [deploy-dev]
if: github.ref == 'refs/heads/main'
environment: staging
steps:
- uses: actions/checkout@v4

- name: Setup Databricks CLI
uses: databricks/setup-cli@main

- name: Deploy to staging environment
run: |
databricks bundle deploy --target staging

- name: Run integration tests
run: |
databricks bundle run demand_forecasting_pipeline --target staging

- name: Validate forecast quality
run: |
# Add data quality validation scripts here
echo "Running forecast quality validation..."

deploy-prod:
name: "Deploy to Production"
runs-on: ubuntu-latest
needs: [deploy-staging]
if: github.ref == 'refs/heads/main'
environment: prod
steps:
- uses: actions/checkout@v4

- name: Setup Databricks CLI
uses: databricks/setup-cli@main

- name: Deploy to production environment
run: |
databricks bundle deploy --target prod

- name: Create deployment tag
run: |
git tag "prod-$(date +%Y%m%d-%H%M%S)"
git push origin --tags

- name: Notify deployment success
run: |
echo "πŸš€ Production deployment successful!"
echo "πŸ“Š Demand forecasting pipeline is now live in production"

cleanup-pr:
name: "Cleanup PR Environment"
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && github.event.action == 'closed'
steps:
- uses: actions/checkout@v4

- name: Setup Databricks CLI
uses: databricks/setup-cli@main

- name: Cleanup PR resources
run: |
# Clean up any PR-specific resources
echo "Cleaning up PR resources..."
# databricks bundle destroy --target pr-${{ github.event.number }}
Loading
Loading