diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index dc17a47..c8ac9ff 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -106,12 +106,20 @@ jobs: - name: Send Notification to Telegram if: env.TG_SENDER_PAYLOAD_MESSAGE != '' && success() + env: + TELEGRAM_BOT_TOKEN: ${{ secrets.BOTTOKEN }} + TELEGRAM_CHAT_ID: ${{ secrets.CHATID }} run: | - curl -X POST \ - -H "Content-Type: application/json" \ - -d '{"chat_id": "${{ secrets.CHATID }}", "text": "${{ env.TG_SENDER_PAYLOAD_MESSAGE }}"}' \ - "https://api.telegram.org/bot${{ secrets.BOTTOKEN }}/sendMessage" - + response=$(curl -s -o /dev/null -w "%{http_code}" -X POST \ + -H "Content-Type: application/json" \ + -d "{\"chat_id\": \"$TELEGRAM_CHAT_ID\", \"text\": \"$TG_SENDER_PAYLOAD_MESSAGE\"}" \ + "https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendMessage") + if [ "$response" = "200" ]; then + echo "Message sent successfully" + else + echo "Failed to send message. HTTP status code: $response" + exit 1 + fi # if: env.TG_SENDER_PAYLOAD_MESSAGE != '' && success() # run: |