-
Notifications
You must be signed in to change notification settings - Fork 15
30 lines (26 loc) · 1.14 KB
/
pr.yml
File metadata and controls
30 lines (26 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
name: notify telegram
on:
pull_request:
types: [opened, reopened, review_requested, closed]
jobs:
notify:
runs-on: ubuntu-latest
steps:
- name: Send Telegram Message
env:
TELEGRAM_BOT_TOKEN: ${{ secrets.WEBOPS_TG_TOKEN }}
CHAT_ID: ${{ secrets.WEBOPS_TG_CHAT_ID }}
TOPIC_ID: ${{ secrets.WEBOPS_TG_PR_MESSAGE_THREAD_ID }}
run: |
PR_TITLE="${{ github.event.pull_request.title }}"
PR_URL="${{ github.event.pull_request.html_url }}"
PR_STATE="${{ github.event.pull_request.state }}"
PR_USER="${{ github.event.pull_request.user.login }}"
PR_NUMBER="${{ github.event.pull_request.number }}"
REPO_NAME=$(echo "${{ github.repository }}" | cut -d'/' -f2)
MESSAGE=$(printf '*%s PR %s %s*\n[%s](%s)\nby *%s*' "$REPO_NAME" "$PR_NUMBER" "${PR_STATE^}" "$PR_TITLE" "$PR_URL" "$PR_USER")
curl -s -X POST "https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendMessage" \
-d chat_id="${CHAT_ID}" \
-d message_thread_id="${TOPIC_ID}" \
-d text="${MESSAGE}" \
-d parse_mode="Markdown"