-
Notifications
You must be signed in to change notification settings - Fork 5
83 lines (79 loc) · 2.69 KB
/
notify_telegram.yml
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
name: Notify Telegram
on:
workflow_dispatch:
push:
paths:
- .github/**
- app/**
- easy-ui/**
- feature-compose/**
- feature/**
- gradle/**
- images/**
- robok/**
- .gitignore
- LICENSE
- README.md
- build.gradle.kts
- gradle.properties
- gradlew
- gradlew.bat
- renovate.json
- settings.gradle.kts
pull_request:
paths:
- .github/**
- app/**
- easy-ui/**
- feature-compose/**
- feature/**
- gradle/**
- images/**
- robok/**
- .gitignore
- LICENSE
- README.md
- build.gradle.kts
- gradle.properties
- gradlew
- gradlew.bat
- renovate.json
- settings.gradle.kts
jobs:
init:
name: Init
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Notify Telegram
env:
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_RBKINC_BOT_TOKEN }}
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_RBKINC_CHAT_ID }}
TELEGRAM_TOPIC_ID: 1100
run: |
if [ "${{ github.event_name }}" = "push" ]; then
commit_message=$(git log -1 --pretty=%B)
commit_hash=$(git log -1 --pretty=%h)
commit_author=$(git log -1 --pretty=%an)
branch_name=$(git rev-parse --abbrev-ref HEAD)
previous_commit_hash=$(git log -2 --pretty=%h | tail -n 1)
repo_url="https://github.com/${{ github.repository }}"
compare_url="${repo_url}/compare/${previous_commit_hash}...${commit_hash}"
commit_url="${repo_url}/commit/${commit_hash}"
message="🔨 [1 new commit](${compare_url}) to Robok-Engine:\`${branch_name}\`%0A%0A[${commit_hash}](${commit_url}): \`${commit_message}\` by \`${commit_author}\`"
elif [ "${{ github.event_name }}" = "pull_request" ]; then
pr_title="${{ github.event.pull_request.title }}"
pr_number="${{ github.event.pull_request.number }}"
pr_author="${{ github.event.pull_request.user.login }}"
pr_url="${{ github.event.pull_request.html_url }}"
message="🔍 [New Update in Pull Request ${pr_number}](${pr_url}) to Robok-Engine:%0A%0A**Title:** \`${pr_title}\`%0A**Author:** \`${pr_author}\`%0A[View PR](${pr_url})"
else
echo "Unsupported event: ${{ github.event_name }}"
exit 1
fi
curl -s -X POST "https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendMessage" \
-d "chat_id=${TELEGRAM_CHAT_ID}" \
-d "parse_mode=Markdown" \
-d "text=${message}" \
-d "message_thread_id=${TELEGRAM_TOPIC_ID}"