#!/bin/bash # Deployment script for sandbox project set -e # Exit on any error echo "Starting deployment process..." # Configuration ENVIRONMENT=${1:-development} BUILD_DIR="./build" BACKUP_DIR="./backups" echo "Environment: $ENVIRONMENT" # Create necessary directories mkdir -p $BUILD_DIR mkdir -p $BACKUP_DIR # Backup current deployment if [ -d "$BUILD_DIR/current" ]; then echo "Creating backup of current deployment..." timestamp=$(date +%Y%m%d_%H%M%S) cp -r $BUILD_DIR/current $BACKUP_DIR/backup_$timestamp fi # Build the project echo "Building project..." if [ -f "package.json" ]; then npm install npm run build fi # Run tests echo "Running tests..." if [ -f "package.json" ]; then npm test fi if [ -f "requirements.txt" ]; then pip install -r requirements.txt pytest tests/ || echo "Python tests not found, skipping..." fi # Deploy echo "Deploying to $ENVIRONMENT..." case $ENVIRONMENT in "production") echo "Production deployment - implementing safety checks..." # Add production-specific deployment steps ;; "staging") echo "Staging deployment..." # Add staging-specific deployment steps ;; "development") echo "Development deployment..." # Add development-specific deployment steps ;; *) echo "Unknown environment: $ENVIRONMENT" exit 1 ;; esac # Health check echo "Performing health check..." # Add health check logic here echo "Deployment completed successfully!" echo "Deployed at: $(date)"