name: PR Telegram Notification on: pull_request: types: [opened, reopened] jobs: notify-telegram: runs-on: ubuntu-latest steps: - name: Send Telegram notification env: BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }} PR_TITLE: ${{ github.event.pull_request.title }} PR_AUTHOR: ${{ github.event.pull_request.user.login }} PR_URL: ${{ github.event.pull_request.html_url }} PR_NUMBER: ${{ github.event.pull_request.number }} REPO_NAME: ${{ github.repository }} run: | 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})" ESCAPED_MESSAGE=$(echo "${MESSAGE}" | sed 's/"/\\"/g' | sed "s/'/\\\'/g") response=$(curl -s -w "%{http_code}" -X POST "https://api.telegram.org/bot${BOT_TOKEN}/sendMessage" \ -H "Content-Type: application/json" \ -d "{ \"chat_id\": \"-1002067867444\", \"text\": \"${ESCAPED_MESSAGE}\", \"message_thread_id\": \"14339\", \"parse_mode\": \"Markdown\", \"disable_web_page_preview\": false }") http_code=${response: -3} if [ "$http_code" -ne 200 ]; then echo "Error: Failed to send Telegram notification (HTTP $http_code)" exit 1 else echo "Telegram notification sent successfully" fi