#!/bin/bash # Script per push automatico verso GitLab set -e # Colori GREEN='\033[0;32m' YELLOW='\033[1;33m' RED='\033[0;31m' NC='\033[0m' echo -e "${GREEN}🚀 Push to GitLab (vt.alfacom.it)${NC}" echo "========================================" # Verifica remote GitLab if ! git remote | grep -q "production"; then echo -e "${YELLOW}⚠️ Remote 'production' non configurato${NC}" echo "Configurazione remote GitLab..." read -p "URL repository GitLab: " GITLAB_URL git remote add production $GITLAB_URL fi # Verifica se ci sono modifiche if [[ -z $(git status -s) ]]; then echo -e "${YELLOW}⚠️ Nessuna modifica da committare${NC}" exit 0 fi # Mostra status echo -e "\n${YELLOW}📋 Modifiche da committare:${NC}" git status -s # Chiedi conferma read -p "Vuoi procedere con il push? (y/N) " -n 1 -r echo if [[ ! $REPLY =~ ^[Yy]$ ]]; then echo -e "${RED}❌ Push annullato${NC}" exit 1 fi # Genera messaggio commit TIMESTAMP=$(date '+%Y-%m-%d %H:%M:%S') COMMIT_MSG="Deploy: $TIMESTAMP" # Chiedi messaggio personalizzato read -p "Messaggio commit personalizzato (Enter per default): " CUSTOM_MSG if [[ ! -z "$CUSTOM_MSG" ]]; then COMMIT_MSG="$CUSTOM_MSG" fi # Git operations echo -e "\n${GREEN}📦 Git add...${NC}" git add . echo -e "${GREEN}💾 Git commit...${NC}" git commit -m "$COMMIT_MSG" echo -e "${GREEN}📤 Git push to production...${NC}" git push production main echo -e "\n${GREEN}✅ Push completato!${NC}" echo "========================================" echo -e "${YELLOW}Deployment automatico disponibile:${NC}" echo "" echo "Sul server esegui:" echo -e "${GREEN} cd /var/www/vigilanza-turni${NC}" echo -e "${GREEN} bash deploy/deploy.sh${NC}" echo "" echo "🌐 Sito: https://vt.alfacom.it" echo ""