diff --git a/.github/workflows/tg_notify.yml b/.github/workflows/tg_notify.yml index 07026ce..4241e6d 100644 --- a/.github/workflows/tg_notify.yml +++ b/.github/workflows/tg_notify.yml @@ -1,48 +1,31 @@ -name: Notify Telegram on Issues and Pull Requests +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 }}" -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] + escape_markdown_v2() { + echo "$1" | sed -e 's/[_*\[\]()~`>#+\-=|{}.!]/\\&/g' + } -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_REPO=$(escape_markdown_v2 "$REPO") + SAFE_EVENT=$(escape_markdown_v2 "$EVENT_TYPE") + SAFE_ACTION=$(escape_markdown_v2 "$ACTION") + SAFE_TITLE=$(escape_markdown_v2 "$TITLE") + SAFE_URL=$(escape_markdown_v2 "$URL") - escape_markdown_v2() { - echo "$1" | sed -e 's/[_*\[\]()~`>#+\-=|{}.!]/\\&/g' - } - - SAFE_REPO=$(escape_markdown_v2 "$REPO") - SAFE_EVENT=$(escape_markdown_v2 "$EVENT_TYPE") - SAFE_ACTION=$(escape_markdown_v2 "$ACTION") - SAFE_TITLE=$(escape_markdown_v2 "$TITLE") - SAFE_URL=$(escape_markdown_v2 "$URL") - - TEXT="*Событие в ${SAFE_REPO}* + TEXT=$(cat <