#!/bin/bash

# Script para hacer push a ambos remotes con diferentes .gitignore

echo "Pushing to Gitea (with deploy folder)..."
# Para Gitea: usar .gitignore normal (incluye deploy/)
git add -A
git commit -m "${1:-Update deployment}" || echo "No changes to commit"
git push gitea main

echo "Pushing to GitHub (without deploy folder)..."
# Para GitHub: usar .gitignore que excluye deploy/
if [ -f .gitignore.github ]; then
    # Backup actual .gitignore
    cp .gitignore .gitignore.backup
    
    # Usar .gitignore específico para GitHub
    cp .gitignore.github .gitignore
    
    # Hacer push sin deploy/
    git add .gitignore
    git rm -r --cached deploy/ 2>/dev/null || true
    git commit -m "${1:-Update without deploy folder}" || echo "No changes to commit"
    git push origin main
    
    # Restaurar .gitignore original
    cp .gitignore.backup .gitignore
    git add .gitignore
    git commit -m "Restore gitignore" || echo "No changes to commit"
else
    echo "No .gitignore.github found, skipping GitHub push"
fi

echo "Done!"