-
Notifications
You must be signed in to change notification settings - Fork 2
54 lines (45 loc) · 1.84 KB
/
github-to-telegram.yml
File metadata and controls
54 lines (45 loc) · 1.84 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
name: GitHub to Telegram
on:
push:
branches:
- master
issues:
types: [opened, closed]
release:
types: [published]
pull_request:
types: [opened, closed, synchronized]
jobs:
notify_telegram:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Send GitHub update to Telegram
run: |
MESSAGE="🚀 *GitHub Update!*\n\n"
MESSAGE+="📌 *Repository:* ${{ github.repository }}\n"
MESSAGE+="🛠 *Event:* ${{ github.event_name }}\n"
if [[ "${{ github.event_name }}" == "push" ]]; then
MESSAGE+="👤 *Pushed by:* ${{ github.actor }}\n"
MESSAGE+="🔹 *Commit Message:* $(git log -1 --pretty=%B)\n"
fi
if [[ "${{ github.event_name }}" == "issues" ]]; then
MESSAGE+="📌 *Issue:* ${{ github.event.issue.title }}\n"
MESSAGE+="🔗 [View Issue](${{ github.event.issue.html_url }})\n"
fi
if [[ "${{ github.event_name }}" == "release" ]]; then
MESSAGE+="🎉 *New Release:* ${{ github.event.release.name }}\n"
MESSAGE+="🔗 [View Release](${{ github.event.release.html_url }})\n"
fi
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
PR_TITLE="${{ github.event.pull_request.title }}"
PR_URL="${{ github.event.pull_request.html_url }}"
PR_ACTION="${{ github.event.action }}"
MESSAGE+="🔄 *Pull Request:* [$PR_TITLE]($PR_URL)\n"
MESSAGE+="🔗 Status: $PR_ACTION\n"
fi
curl -s -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" \
-d "chat_id=${{ secrets.TELEGRAM_CHAT_ID }}" \
--data-urlencode "text=$(echo -e "$MESSAGE")" \
-d "parse_mode=Markdown"