-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
79 lines (65 loc) · 2.39 KB
/
Copy pathdeploy.sh
File metadata and controls
79 lines (65 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
# deploy.sh — Déploiement de ha-image-viewer depuis GitHub vers Home Assistant
# Usage : ./deploy.sh [--rebuild] [--no-restart]
# --rebuild : Force la reconstruction du conteneur Docker (nécessaire si Dockerfile ou image-viewer.py changé)
# --no-restart : Pull uniquement, sans redémarrer ni reconstruire
# Afin d'éviter les erreurs de changements locaux en faisant les chmod +x des scripts .sh
# on peut désactiver le suivi des permissions dans git sur HA avec la commande:
# git config core.fileMode false
set -e
APP_DIR=~/addons/dc_apps/image_viewer
APP_SLUG=local_dc_image_viewer
BRANCH=main
echo "======================================"
echo " Déploiement ha-image-viewer"
echo "======================================"
# Vérifier que le répertoire existe
if [ ! -d "$APP_DIR" ]; then
echo "❌ Répertoire $APP_DIR introuvable"
exit 1
fi
cd "$APP_DIR"
# Vérifier que c'est bien un repo git
if [ ! -d ".git" ]; then
echo "⚠️ Pas de repo git trouvé — initialisation..."
git init
git remote add origin $(git -C ~/devel/ha-image-viewer remote get-url origin 2>/dev/null || echo "")
if [ -z "$(git remote get-url origin 2>/dev/null)" ]; then
echo "❌ Impossible de trouver l'URL du remote. Configurez-la manuellement :"
echo " git remote add origin https://github.com/qcda1/ha-image-viewer.git"
exit 1
fi
fi
# Pull depuis GitHub
echo ""
echo "📥 Récupération des dernières modifications depuis GitHub ($BRANCH)..."
git fetch origin
git reset --hard origin/"$BRANCH"
chmod +x deploy.sh run.sh
echo ""
echo "📋 Derniers commits déployés :"
git --no-pager log --oneline -5
# Rebuild ou restart selon l'option
if [ "$1" == "--no-restart" ]; then
echo ""
echo "⏭️ Redémarrage ignoré (--no-restart)"
elif [ "$1" == "--rebuild" ]; then
echo ""
echo "🔨 Reconstruction du conteneur Docker..."
ha apps rebuild "$APP_SLUG"
echo "✅ Reconstruction terminée"
echo ""
echo "🔄 Démarrage de l'addon $APP_SLUG..."
ha apps start "$APP_SLUG"
echo "✅ App démarré"
else
echo ""
echo "🔄 Redémarrage de l'app $APP_SLUG..."
ha app restart "$APP_SLUG"
echo "✅ App redémarré"
echo ""
echo "💡 Si les changements ne sont pas visibles, relancez avec : ./deploy.sh --rebuild"
fi
echo ""
echo "✅ Déploiement terminé !"
echo "======================================"