watch script robustness

This commit is contained in:
nomadics9 2024-12-30 05:12:11 +03:00
parent 4d458e27e8
commit 191a681caa

View file

@ -1,21 +1,28 @@
#!/bin/sh #!/bin/sh
if [ -f .botenv ]; then if [ -f .botenv ]; then
export $(grep -v '^#' .botenv | xargs) export $(grep -v '^#' .botenv | xargs)
fi fi
LAST_RELEASE_FILE=/data/alaskartv/androidtv-ci/release.txt 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') 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 if [ -f "$LAST_RELEASE_FILE" ]; then
read -r version < "$LAST_RELEASE_FILE" read -r version < "$LAST_RELEASE_FILE"
else else
version="" version=""
fi fi
echo "Current Version: '$version'"
echo "Comparison result: $latest_release != $version"
if [ "$latest_release" != "$version" ]; then if [ "$latest_release" != "$version" ]; then
# echo "$latest_release" > "$LAST_RELEASE_FILE" echo "Versions are different, updating..."
curl -X POST "https://api.telegram.org/bot$BOT_TOKEN/sendMessage" \ curl -X POST "https://api.telegram.org/bot$BOT_TOKEN/sendMessage" \
-d chat_id="$CHAT_ID" \ -d chat_id="$CHAT_ID" \
-d text="🚀 New Release Detected: $latest_release on $REPO_OWNER/$REPO_NAME" -d text="🚀 New Release Detected: $latest_release on $REPO_OWNER/$REPO_NAME"
curl -X POST "http://api-server:9090/api/alaskartv" curl -X POST "http://api-server:9090/api/alaskartv"
else
echo "Versions are the same, no update needed"
fi fi