From 191a681caa5dd6770e1694823c6f55a431984840 Mon Sep 17 00:00:00 2001 From: nomadics9 Date: Mon, 30 Dec 2024 05:12:11 +0300 Subject: [PATCH] watch script robustness --- watchTV.sh | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/watchTV.sh b/watchTV.sh index 6f00bcb..c736807 100755 --- a/watchTV.sh +++ b/watchTV.sh @@ -1,21 +1,28 @@ #!/bin/sh - if [ -f .botenv ]; then export $(grep -v '^#' .botenv | xargs) fi LAST_RELEASE_FILE=/data/alaskartv/androidtv-ci/release.txt - latest_release=$(curl -s "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/releases/latest" | jq -r '.tag_name') + +echo "Latest Release: '$latest_release'" + if [ -f "$LAST_RELEASE_FILE" ]; then read -r version < "$LAST_RELEASE_FILE" else version="" fi + +echo "Current Version: '$version'" + +echo "Comparison result: $latest_release != $version" if [ "$latest_release" != "$version" ]; then - # echo "$latest_release" > "$LAST_RELEASE_FILE" - curl -X POST "https://api.telegram.org/bot$BOT_TOKEN/sendMessage" \ - -d chat_id="$CHAT_ID" \ - -d text="🚀 New Release Detected: $latest_release on $REPO_OWNER/$REPO_NAME" - curl -X POST "http://api-server:9090/api/alaskartv" + echo "Versions are different, updating..." + curl -X POST "https://api.telegram.org/bot$BOT_TOKEN/sendMessage" \ + -d chat_id="$CHAT_ID" \ + -d text="🚀 New Release Detected: $latest_release on $REPO_OWNER/$REPO_NAME" + curl -X POST "http://api-server:9090/api/alaskartv" +else + echo "Versions are the same, no update needed" fi