Skip to content

Telegram Notification #2

Telegram Notification

Telegram Notification #2

name: Telegram Notification
on:
workflow_run:
workflows: ["CI"]
types:
- completed
branches:
- master
jobs:
send_telegram_notification:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: πŸ“₯ Download APK artifact
uses: actions/download-artifact@v4
with:
name: noah-android-apk-*
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- name: πŸ” Find APK filename
id: find_apk
run: |
apk_file=$(ls *.apk | head -n 1)
echo "apk_filename=${apk_file}" >> $GITHUB_OUTPUT
shell: bash
- name: πŸš€ Start local Telegram Bot API server
run: |
docker run -d --name local-bot-api \
-p 8081:8081 \
-v ${{ github.workspace }}:/data \
-e TELEGRAM_API_ID=${{ secrets.TELEGRAM_API_ID }} \
-e TELEGRAM_API_HASH=${{ secrets.TELEGRAM_API_HASH }} \
aiogram/telegram-bot-api:latest --local
- name: ⏳ Wait for Bot API server to be ready
run: |
echo "Waiting 5 seconds for the local Bot API server to initialize..."
sleep 5
- name: πŸ“€ Send APK using local Bot API server
run: |
curl -s -X POST "http://localhost:8081/bot${{ secrets.TELEGRAM_TOKEN }}/sendDocument" \
-F chat_id="${{ secrets.BLIXT_CHAT_ID }}" \
-F message_thread_id="${{ secrets.BLIXT_TOPIC_ID }}" \
-F document=@"${{ steps.find_apk.outputs.apk_filename }}" \
-F caption="New Noah Android build is available!
Commit: ${{ github.event.workflow_run.head_sha }}
Message: ${{ github.event.workflow_run.head_commit.message }}"
- name: πŸ›‘ Stop and remove local Bot API server
if: always()
run: |
echo "Stopping and removing the Docker container..."
docker stop local-bot-api
docker rm local-bot-api