groldsf_obsidian_check_plugin/.github/workflows/tg_notify.yml
2025-03-13 21:44:47 +03:00

33 lines
No EOL
1.4 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: Notify Telegram on Issues and Pull Requests
on:
issues:
types: [opened, edited, reopened]
pull_request:
types: [opened, edited, reopened, review_requested, ready_for_review, synchronize]
issue_comment:
types: [created]
pull_request_review:
types: [submitted]
jobs:
notify:
runs-on: ubuntu-latest
steps:
- name: Send Telegram Notification
env:
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
run: |
REPO="${{ github.repository }}"
EVENT_TYPE="${{ github.event_name }}"
ACTION="${{ github.event.action }}"
TITLE="${{ github.event.issue.title || github.event.pull_request.title || 'Комментарий' }}"
URL="${{ github.event.issue.html_url || github.event.pull_request.html_url || github.event.comment.html_url || github.event.review.html_url }}"
SAFE_TITLE=$(echo "$TITLE" | sed 's/`/\\`/g' | sed 's/(/\\(/g' | sed 's/)/\\)/g')
TEXT="*Событие в ${REPO}*\nТип: \`${EVENT_TYPE}\`\nДействие: \`${ACTION}\`\nЗаголовок: \`${SAFE_TITLE}\`\n[Открыть](${URL})"
curl -s -X POST \
https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendMessage \
-d chat_id=${TELEGRAM_CHAT_ID} \
-d parse_mode=Markdown \
-d "text=${TEXT}"