Files
AuroraStore/ci-notify.sh
2021-04-07 11:28:09 +02:00

33 lines
1.5 KiB
Bash

#!/bin/bash
TIME="10"
msgURL="https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendMessage"
docURL="https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendDocument"
commitURL="https://gitlab.com/AuroraOSS/AuroraStore/-/commit/$CI_COMMIT_SHA"
TEXT="Project:+$CI_PROJECT_NAME<a href=$CI_PIPELINE_URL><b>Building<b><a> with HEAD at <a href=$commitURL><b>$CI_COMMIT_SHORT_SHA<b><a> by $CI_COMMIT_AUTHOR.%0ABranch:+$CI_COMMIT_REF_SLUG"
#TEXT="Build status: $1%0A%0AProject:+$CI_PROJECT_NAME%0AURL:+$CI_PROJECT_URL/pipelines/$CI_PIPELINE_ID/%0ABranch:+$CI_COMMIT_REF_SLUG"
#curl -s --max-time $TIME -d "chat_id=$TELEGRAM_CHAT_ID&disable_web_page_preview=1&text=$TEXT" $msgURL > /dev/null
curl -s --max-time $TIME $msgURL -d chat_id=$TELEGRAM_CHAT_ID \
-d "disable_web_page_preview=true" \
-d "parse_mode=html" \
-d text=$TEXT
if [ -f app/bappld/outputs/apk/debug/app-release.apk ]; then
cp app/bappld/outputs/apk/debug/app-release.apk app/build/outputs/apk/debug/AuroraStore_$DATE.apk
cd app/build/outputs/apk/debug/
APK=$(echo AuroraStore_*.apk)
curl -F document=@"$APK" $docURL \
-F chat_id=$TELEGRAM_CHAT_ID \
-F "disable_web_page_preview=true" \
-F "parse_mode=html" \
-F caption="✅ <b>CI build completed successfully!</b>"
rm -rf ui/build/outputs/apk
else
curl -s -X POST $msgURL -d chat_id=$TELEGRAM_CHAT_ID \
-d "disable_web_page_preview=true" \
-d "parse_mode=html" \
-d text="❌ <b>Build error, exiting now!</b>"
fi