Skip to content

Commit 6304f5a

Browse files
update: community-release-notifier with Telegram support
Updated community release notifier workflow to include Telegram notifications and improved variable handling.
1 parent 2c7d05a commit 6304f5a

File tree

1 file changed

+86
-29
lines changed

1 file changed

+86
-29
lines changed
Lines changed: 86 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,101 @@
11
name: community-release-notifier
2+
23
on:
34
release:
45
types: [ released ]
56
workflow_call:
67
inputs:
7-
tag_name:
8-
required: true
9-
description: "Release tag_name"
10-
type: 'string'
11-
url:
12-
required: true
13-
description: "release URL"
14-
type: 'string'
15-
body:
16-
required: true
17-
description: "Release Body"
18-
type: 'string'
19-
default: ''
8+
tag_name:
9+
required: true
10+
description: "Release tag_name"
11+
type: 'string'
12+
url:
13+
required: true
14+
description: "release URL"
15+
type: 'string'
16+
body:
17+
required: true
18+
description: "Release Body"
19+
type: 'string'
20+
default: ''
2021
secrets:
2122
DISCORD_WEBHOOK_RELEASE_NOTES:
2223
description: 'Discord Webhook for Notifying Releases to Discord'
2324
required: true
25+
TELEGRAM_BOT_TOKEN:
26+
description: 'Telegram Bot Token'
27+
required: true
28+
TELEGRAM_CHAT_ID:
29+
description: 'Telegram Chat ID (group/channel/supergroup)'
30+
required: true
31+
TELEGRAM_MESSAGE_THREAD_ID:
32+
description: 'Optional: Topic / message_thread_id for Telegram forum/topic'
33+
required: false
2434

2535
jobs:
26-
discord-release:
36+
notify:
2737
if: github.repository_owner == 'Acode-Foundation'
2838
runs-on: ubuntu-latest
2939
steps:
30-
- name: Get Release Content
31-
id: get-release-content
32-
uses: 2428392/gh-truncate-string-action@b3ff790d21cf42af3ca7579146eedb93c8fb0757 # v1.4.1
33-
with:
34-
maxLength: 2000
35-
stringToTruncate: |
36-
📢 Acode [${{ github.event.release.tag_name || inputs.tag_name }}](<${{ github.event.release.url || inputs.url }}>) was just Released 🎉!
37-
38-
${{ github.event.release.body || inputs.body }}
39-
40-
- name: Discord Webhook Action (Publishing)
41-
uses: tsickert/discord-webhook@c840d45a03a323fbc3f7507ac7769dbd91bfb164 # v5.3.0
42-
with:
43-
webhook-url: ${{ secrets.DISCORD_WEBHOOK_RELEASE_NOTES }}
44-
content: ${{ steps.get-release-content.outputs.string }}
40+
- name: Prepare release variables
41+
id: vars
42+
run: |
43+
TAG="${{ github.event.release.tag_name || inputs.tag_name }}"
44+
URL="${{ github.event.release.url || inputs.url }}"
45+
# Escape problematic characters for MarkdownV2 (very conservative escaping)
46+
# We escape: _ * [ ] ( ) ~ ` > # + - = | { } . ! \
47+
BODY_SAFE=$(printf '%s' "${{ github.event.release.body || inputs.body }}" | \
48+
sed 's/[_*[\]()~`>#+-=|{}.!\\]/\\&/g')
49+
50+
if [[ "$TAG" == *"-nightly"* ]]; then
51+
SUFFIX=" (Nightly Release)"
52+
else
53+
SUFFIX=""
54+
fi
55+
56+
# Announcement line — also escape for safety
57+
ANNOUNCE_SAFE="📢 Acode \[$TAG\]($URL) was just Released 🎉$SUFFIX!"
58+
59+
echo "announce=$ANNOUNCE_SAFE" >> $GITHUB_OUTPUT
60+
echo "body_safe=$BODY_SAFE" >> $GITHUB_OUTPUT
61+
62+
# ────────────────────────────────────────────────
63+
# Truncate for Discord
64+
# ────────────────────────────────────────────────
65+
- name: Truncate message for Discord
66+
id: truncate-discord
67+
uses: 2428392/gh-truncate-string-action@b3ff790d21cf42af3ca7579146eedb93c8fb0757 # v1.4.1
68+
with:
69+
maxLength: 2000
70+
stringToTruncate: |
71+
${{ steps.vars.outputs.announce }}
72+
73+
${{ steps.vars.outputs.body_safe }}
74+
75+
# ────────────────────────────────────────────────
76+
# Discord notification
77+
# ────────────────────────────────────────────────
78+
- name: Discord Webhook (Publishing)
79+
uses: tsickert/discord-webhook@c840d45a03a323fbc3f7507ac7769dbd91bfb164 # v5.3.0
80+
with:
81+
webhook-url: ${{ secrets.DISCORD_WEBHOOK_RELEASE_NOTES }}
82+
content: ${{ steps.truncate-discord.outputs.string }}
83+
continue-on-error: true
84+
85+
# ────────────────────────────────────────────────
86+
# Telegram notification — MarkdownV2 + no link preview
87+
# ────────────────────────────────────────────────
88+
- name: Send to Telegram
89+
uses: appleboy/telegram-action@v1.0.0 # or newer tag if available
90+
with:
91+
to: ${{ secrets.TELEGRAM_CHAT_ID }}
92+
token: ${{ secrets.TELEGRAM_BOT_TOKEN }}
93+
message: |
94+
${{ steps.vars.outputs.announce }}
95+
96+
${{ steps.vars.outputs.body_safe }}
97+
parse_mode: MarkdownV2
98+
disable_web_page_preview: true
99+
# Only needed for topic-enabled supergroups/channels
100+
message_thread_id: ${{ secrets.TELEGRAM_MESSAGE_THREAD_ID }}
101+
continue-on-error: true

0 commit comments

Comments
 (0)