Skip to content

Commit 062d6a1

Browse files
authored
chore: send Telegram notification only if download links exist (#84)
1 parent 8b31429 commit 062d6a1

File tree

1 file changed

+33
-10
lines changed

1 file changed

+33
-10
lines changed

.github/workflows/dart.yml

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -743,17 +743,40 @@ jobs:
743743
curl -H "Content-Type: application/json" \
744744
-d "{\"content\": \"${APK_MESSAGE}\n${WINDOWS_MESSAGE}\n${LINUX_MESSAGE}\n${IOS_MESSAGE}\n${MACOS_MESSAGE}\"}" \
745745
"${{ secrets.DISCORD_WEBHOOK_URL }}"
746+
746747
- name: Send Telegram Notification
747748
run: |
748-
response=$(curl -sS -f -X POST \
749-
"https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKKEN}}/sendMessage" \
750-
-F "chat_id=${{ secrets.TELEGRAM_CHANNEL_ID}}" \
751-
-F "message_thread_id=${{secrets.TELEGRAM_THREAD_ID}}" \
749+
MESSAGE="🎉 *Build Notification* 🎉"
750+
751+
if [[ -n "${{ env.apk_message }}" ]]; then
752+
MESSAGE="$MESSAGE
753+
${{ env.apk_message }}"
754+
fi
755+
if [[ -n "${{ env.windows_message }}" ]]; then
756+
MESSAGE="$MESSAGE
757+
${{ env.windows_message }}"
758+
fi
759+
if [[ -n "${{ env.linux_message }}" ]]; then
760+
MESSAGE="$MESSAGE
761+
${{ env.linux_message }}"
762+
fi
763+
if [[ -n "${{ env.ios_message }}" ]]; then
764+
MESSAGE="$MESSAGE
765+
${{ env.ios_message }}"
766+
fi
767+
if [[ -n "${{ env.macos_message }}" ]]; then
768+
MESSAGE="$MESSAGE
769+
${{ env.macos_message }}"
770+
fi
771+
772+
if [[ "$MESSAGE" != "🎉 *Build Notification* 🎉" ]]; then
773+
curl -sS -f -X POST \
774+
"https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKKEN }}/sendMessage" \
775+
-F "chat_id=${{ secrets.TELEGRAM_CHANNEL_ID }}" \
776+
-F "message_thread_id=${{ secrets.TELEGRAM_THREAD_ID }}" \
752777
-F parse_mode="Markdown" \
753778
-F disable_notification=true \
754-
-F "text=🎉 *Build Notification* 🎉
755-
${{ env.apk_message }}
756-
${{ env.windows_message }}
757-
${{ env.linux_message }}
758-
${{ env.ios_message }}
759-
${{ env.macos_message }}")
779+
-F "text=$MESSAGE"
780+
else
781+
echo "No download links found. Skipping Telegram notification."
782+
fi

0 commit comments

Comments
 (0)