#!/usr/bin/bash # Weather App Deployment Script set -e # Exit on error echo "đŸŒ¤ī¸ Weather App Deployment" # Get project name from user echo "📝 Enter your Ghaymah PROJECT name:" read project_name # Validate project name if [ -z "$project_name" ]; then echo "❌ Project name cannot be empty!" exit 1 fi # Get app name from user echo "📝 Enter your APP name (this will be the deployed application name):" read app_name # Validate app name if [ -z "$app_name" ]; then echo "❌ App name cannot be empty!" exit 1 fi # Configuration IMAGENAME="$app_name" # Use app name for image DOCKER_USERNAME="ahmedgamalyousef" # Your Docker Hub username echo "🚀 Starting deployment..." echo " Project: ${project_name}" echo " App: ${app_name}" echo " Image: ${IMAGENAME}" # Build Docker image echo "đŸ—ī¸ Building ${IMAGENAME} image..." # Get current tag and increment tag=$(docker image ls | grep ${IMAGENAME} | awk '{print $2}' | head -1) if [ -z "${tag}" ]; then new_tag=1 echo "📌 No existing image found, starting with version 1" else echo "📌 Found existing tag: ${tag}" docker rmi ${IMAGENAME}:${tag} || echo "âš ī¸ Could not remove old image, continuing..." new_tag=$((tag + 1)) fi # Build the image echo "🔨 Building version ${new_tag}..." docker build -t ${IMAGENAME}:${new_tag} . # Push to Docker Hub echo "📤 Pushing to Docker Hub..." docker tag ${IMAGENAME}:${new_tag} ${DOCKER_USERNAME}/${IMAGENAME}:${new_tag} docker push ${DOCKER_USERNAME}/${IMAGENAME}:${new_tag} # Also tag as latest docker tag ${IMAGENAME}:${new_tag} ${DOCKER_USERNAME}/${IMAGENAME}:latest docker push ${DOCKER_USERNAME}/${IMAGENAME}:latest echo "✅ Image pushed: ${DOCKER_USERNAME}/${IMAGENAME}:${new_tag}" # Ghaymah deployment if command -v gy &> /dev/null; then echo "â˜ī¸ Setting up Ghaymah deployment..." # Create project with the project name echo "🔧 Creating project: ${project_name}" project_id=$(gy resource project create --set .name=${project_name} | awk '/ID:/ {print $NF}') if [ -z "$project_id" ]; then echo "❌ Failed to get project ID" exit 1 fi echo "✅ Project ID: ${project_id}" # Create .ghaymah.json configuration using both names cat > .ghaymah.json <