fix(update): detect real image changes and improve webhook messages

Use image ID diff instead of grepping "Pulled" (which appears even
when images are already up to date). Add timestamp, stack count, and
updated/total ratio to all notification messages.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-12 07:58:55 +02:00
parent 2130069836
commit d4327bd152
+14 -8
View File
@@ -18,7 +18,7 @@ notify() {
: > "$LOG_FILE" : > "$LOG_FILE"
log "Starting image update check" log "Starting image update check"
updated=(); failed=() updated=(); failed=(); checked=0
for stack_dir in "$STACKS_DIR"/*/; do for stack_dir in "$STACKS_DIR"/*/; do
stack=$(basename "$stack_dir") stack=$(basename "$stack_dir")
@@ -27,9 +27,13 @@ for stack_dir in "$STACKS_DIR"/*/; do
log "Checking $stack" log "Checking $stack"
cd "$stack_dir" cd "$stack_dir"
pull_output=$(docker compose pull 2>&1 | tee -a "$LOG_FILE") checked=$((checked + 1))
if echo "$pull_output" | grep -q " Pulled"; then before=$(docker compose images -q 2>/dev/null | sort)
docker compose pull 2>&1 | tee -a "$LOG_FILE"
after=$(docker compose images -q 2>/dev/null | sort)
if [ "$before" != "$after" ]; then
log " Updates found — recreating containers" log " Updates found — recreating containers"
if docker compose up -d 2>&1 | tee -a "$LOG_FILE"; then if docker compose up -d 2>&1 | tee -a "$LOG_FILE"; then
updated+=("$stack") updated+=("$stack")
@@ -45,12 +49,14 @@ done
log "Pruning dangling images" log "Pruning dangling images"
docker image prune -f 2>&1 | tee -a "$LOG_FILE" docker image prune -f 2>&1 | tee -a "$LOG_FILE"
if [ ${#updated[@]} -eq 0 ] && [ ${#failed[@]} -eq 0 ]; then date_str=$(date '+%Y-%m-%d %H:%M')
notify "#36a64f" "✅ **Update check complete** — all images up to date"
elif [ ${#failed[@]} -gt 0 ]; then if [ ${#failed[@]} -gt 0 ]; then
notify "#cc0000" "❌ **Update failed**\nUpdated: ${updated[*]:-none}\nFailed: ${failed[*]}" notify "#cc0000" "❌ **Update failed**$date_str\nUpdated: ${updated[*]:-none}\nFailed: ${failed[*]}"
elif [ ${#updated[@]} -gt 0 ]; then
notify "#36a64f" "✅ **Updates applied** — $date_str\nStacks updated (${#updated[@]}/$checked): ${updated[*]}"
else else
notify "#36a64f" "✅ **Updates applied**\nStacks: ${updated[*]}" notify "#36a64f" "✅ **All up to date** — $date_str ($checked stacks checked)"
fi fi
log "Update check complete" log "Update check complete"