#!/bin/bash
# SiteMente Deployment Script

BRANCH=${1:-develop}
ACTION=${2:-push}

echo "=== SiteMente Deployment ==="
echo "Branch: $BRANCH"
echo "Action: $ACTION"
echo ""

case $ACTION in
  push)
    echo "Pushing to $BRANCH..."
    git checkout $BRANCH
    git add -A
    git commit -m "Update: $(date '+%Y-%m-%d %H:%M')" || echo "Nothing to commit"
    git push origin $BRANCH
    echo "✅ Pushed to $BRANCH"
    ;;
  
  merge)
    echo "Merging $BRANCH to main..."
    git checkout main
    git merge $BRANCH
    git push origin main
    echo "✅ Merged and pushed to main"
    ;;
    
  deploy)
    echo "Deploying $BRANCH..."
    git checkout $BRANCH
    git add -A
    git commit -m "Deploy: $(date '+%Y-%m-%d %H:%M')" || echo "Nothing to commit"
    git push origin $BRANCH
    echo "✅ Deployed $BRANCH"
    ;;
    
  status)
    echo "=== Current Status ==="
    echo "Working branch: $(git branch --show-current)"
    echo ""
    echo "Branches:"
    git branch -a
    echo ""
    echo "Recent commits:"
    git log --oneline -5
    ;;
    
  *)
    echo "Usage: ./deploy.sh <branch> <action>"
    echo ""
    echo "Actions:"
    echo "  push   - Commit and push changes"
    echo "  merge  - Merge branch to main"
    echo "  deploy - Commit, push (alias for push)"
    echo "  status - Show current status"
    ;;
esac
