-
Notifications
You must be signed in to change notification settings - Fork 1
53 lines (47 loc) · 1.63 KB
/
release-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
42
43
44
45
46
47
48
49
50
51
52
53
name: send notifications
on:
workflow_call:
secrets:
TELEGRAM_INFO_BOT_ID:
description: 'telegram bot id'
required: true
TELEGRAM_INFO_CHANNEL_ID:
description: 'channel id'
required: true
inputs:
message_append:
type: string
default: ""
message_prepend:
type: string
default: ""
message_body_command:
type: string
default: ""
jobs:
notify_telegram:
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
- run: sudo apt install jq
- name: "post to telegram"
shell: bash
env:
TELEGRAM_BOT_SECRET: ${{ secrets.TELEGRAM_INFO_BOT_ID }}
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_INFO_CHANNEL_ID }}
MSG_PREPEND: ${{ inputs.message_prepend }}
MSG_APPEND: ${{ inputs.message_append }}
run: |
git fetch --tags --force
echo '#!/usr/bin/env bash' > send_update.sh
echo '{"chat_id":'"$TELEGRAM_CHAT_ID"',"text":' > info_message
(
printf "$MSG_PREPEND"
${{ inputs.message_body_command }}
printf "$MSG_APPEND"
) | jq -Rsa . >> info_message
echo '}' >> info_message
# only for curl8
# curl --variable '%TELEGRAM_BOT_SECRET' --expand-url="https://api.telegram.org/bot{{TELEGRAM_BOT_SECRET}}/sendMessage" --json @info_message > /dev/null
curl -s -X POST -H "Content-Type:application/json" "https://api.telegram.org/bot""${TELEGRAM_BOT_SECRET}""/sendMessage" --data @info_message > /dev/null
rm info_message