Add a git pull before pushing to production to synchronize remote changes and avoid conflicts. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 42d8028a-fa71-4ec2-938c-e43eedf7df01 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/6d543d2c-20b9-4ea6-93fe-70fe9b1d9f80/42d8028a-fa71-4ec2-938c-e43eedf7df01/aazyBOE
76 lines
1.9 KiB
Bash
76 lines
1.9 KiB
Bash
#!/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}"
|
|
|
|
# Pull prima di pushare per evitare conflitti
|
|
echo -e "${YELLOW}Sincronizzazione con remote...${NC}"
|
|
git pull production main --no-rebase || echo -e "${YELLOW}⚠️ Potrebbero esserci conflitti da risolvere${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 ""
|