https://dev.kronoz.win/r/marzneshin.git
1name: PR Telegram Notification
2
3on:
4 pull_request:
5 types: [opened, reopened]
6
7jobs:
8 notify-telegram:
9 runs-on: ubuntu-latest
10
11 steps:
12 - name: Send Telegram notification
13 env:
14 BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
15 PR_TITLE: ${{ github.event.pull_request.title }}
16 PR_AUTHOR: ${{ github.event.pull_request.user.login }}
17 PR_URL: ${{ github.event.pull_request.html_url }}
18 PR_NUMBER: ${{ github.event.pull_request.number }}
19 REPO_NAME: ${{ github.repository }}
20 run: |
21
22 MESSAGE="🔄 *New Pull Request*\\n📝 *Title:* ${PR_TITLE}\\n👤 *Author:* ${PR_AUTHOR}\\n🔢 *PR #${PR_NUMBER}*\\n🏷️ *Repo:* ${REPO_NAME}\\n🔗 [View Pull Request](${PR_URL})"
23
24 ESCAPED_MESSAGE=$(echo "${MESSAGE}" | sed 's/"/\\"/g' | sed "s/'/\\\'/g")
25
26
27 response=$(curl -s -w "%{http_code}" -X POST "https://api.telegram.org/bot${BOT_TOKEN}/sendMessage" \
28 -H "Content-Type: application/json" \
29 -d "{
30 \"chat_id\": \"-1002067867444\",
31 \"text\": \"${ESCAPED_MESSAGE}\",
32 \"message_thread_id\": \"14339\",
33 \"parse_mode\": \"Markdown\",
34 \"disable_web_page_preview\": false
35 }")
36
37 http_code=${response: -3}
38 if [ "$http_code" -ne 200 ]; then
39 echo "Error: Failed to send Telegram notification (HTTP $http_code)"
40 exit 1
41 else
42 echo "Telegram notification sent successfully"
43 fi