-
-
Notifications
You must be signed in to change notification settings - Fork 155
41 lines (36 loc) · 1.11 KB
/
telegram-notify.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
name: Notify
permissions:
contents: read
on:
push:
branches:
- main
jobs:
notify:
name: Notify via Telegram
runs-on: ubuntu-latest
env:
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHANNEL_ID }}
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
steps:
- name: Notify
if: env.TELEGRAM_CHAT_ID && env.TELEGRAM_TOKEN
env:
COMMITS: ${{ toJson(github.event.commits) }}
TEMPLATE: '.[] | "<a href=\"\(.url)\">\(.id[:8])</a> • <a href=\"https://github.com/\(.author.username | @html)\">\(.author.username | @html)</a>
\(.message | gsub("(?<a>[<>&\"])"; .a|@html))
"'
run: |
(
printenv COMMITS | jq -r "$TEMPLATE"
printf '@RethinkDNS_Channel'
) | \
jq -R --slurp '{
text: .,
disable_web_page_preview: true,
chat_id: "$TELEGRAM_CHAT_ID",
parse_mode: "HTML"
}' | \
curl -X POST https://api.telegram.org/bot$TELEGRAM_TOKEN/sendMessage \
-H 'Content-Type: application/json' \
--data-binary @-