-
Notifications
You must be signed in to change notification settings - Fork 960
Add Telegram Notifier to Nightly CI pipeline #1934
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
4070b34
f37982c
6304f5a
7b5553f
2da06c5
800135d
5837e13
c5828d6
72e1f2f
9051f44
3c783f6
4c397d5
67cb0a2
4fc3f05
60e7bab
c57a866
6710bc5
5d852f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,44 +1,101 @@ | ||
| name: community-release-notifier | ||
|
|
||
| on: | ||
| release: | ||
| types: [ released ] | ||
| workflow_call: | ||
| inputs: | ||
| tag_name: | ||
| required: true | ||
| description: "Release tag_name" | ||
| type: 'string' | ||
| url: | ||
| required: true | ||
| description: "release URL" | ||
| type: 'string' | ||
| body: | ||
| required: true | ||
| description: "Release Body" | ||
| type: 'string' | ||
| default: '' | ||
| tag_name: | ||
| required: true | ||
| description: "Release tag_name" | ||
| type: 'string' | ||
| url: | ||
| required: true | ||
| description: "release URL" | ||
| type: 'string' | ||
| body: | ||
| required: true | ||
| description: "Release Body" | ||
| type: 'string' | ||
| default: '' | ||
| secrets: | ||
| DISCORD_WEBHOOK_RELEASE_NOTES: | ||
| description: 'Discord Webhook for Notifying Releases to Discord' | ||
| required: true | ||
| TELEGRAM_BOT_TOKEN: | ||
| description: 'Telegram Bot Token' | ||
| required: true | ||
| TELEGRAM_CHAT_ID: | ||
| description: 'Telegram Chat ID (group/channel/supergroup)' | ||
| required: true | ||
| TELEGRAM_MESSAGE_THREAD_ID: | ||
| description: 'Optional: Topic / message_thread_id for Telegram forum/topic' | ||
| required: false | ||
|
UnschooledGamer marked this conversation as resolved.
Outdated
|
||
|
|
||
| jobs: | ||
| discord-release: | ||
| notify: | ||
| if: github.repository_owner == 'Acode-Foundation' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Get Release Content | ||
| id: get-release-content | ||
| uses: 2428392/gh-truncate-string-action@b3ff790d21cf42af3ca7579146eedb93c8fb0757 # v1.4.1 | ||
| with: | ||
| maxLength: 2000 | ||
| stringToTruncate: | | ||
| 📢 Acode [${{ github.event.release.tag_name || inputs.tag_name }}](<${{ github.event.release.url || inputs.url }}>) was just Released 🎉! | ||
|
|
||
| ${{ github.event.release.body || inputs.body }} | ||
|
|
||
| - name: Discord Webhook Action (Publishing) | ||
| uses: tsickert/discord-webhook@c840d45a03a323fbc3f7507ac7769dbd91bfb164 # v5.3.0 | ||
| with: | ||
| webhook-url: ${{ secrets.DISCORD_WEBHOOK_RELEASE_NOTES }} | ||
| content: ${{ steps.get-release-content.outputs.string }} | ||
| - name: Prepare release variables | ||
| id: vars | ||
| run: | | ||
| TAG="${{ github.event.release.tag_name || inputs.tag_name }}" | ||
| URL="${{ github.event.release.url || inputs.url }}" | ||
| # Escape problematic characters for MarkdownV2 (very conservative escaping) | ||
| # We escape: _ * [ ] ( ) ~ ` > # + - = | { } . ! \ | ||
| BODY_SAFE=$(printf '%s' "${{ github.event.release.body || inputs.body }}" | \ | ||
| sed 's/[_*[\]()~`>#+-=|{}.!\\]/\\&/g') | ||
|
UnschooledGamer marked this conversation as resolved.
Outdated
|
||
|
|
||
| if [[ "$TAG" == *"-nightly"* ]]; then | ||
| SUFFIX=" (Nightly Release)" | ||
| else | ||
| SUFFIX="" | ||
| fi | ||
|
|
||
| # Announcement line — also escape for safety | ||
| ANNOUNCE_SAFE="📢 Acode \[$TAG\]($URL) was just Released 🎉$SUFFIX!" | ||
|
UnschooledGamer marked this conversation as resolved.
Outdated
|
||
|
|
||
| echo "announce=$ANNOUNCE_SAFE" >> $GITHUB_OUTPUT | ||
| echo "body_safe=$BODY_SAFE" >> $GITHUB_OUTPUT | ||
|
UnschooledGamer marked this conversation as resolved.
Outdated
|
||
|
|
||
| # ──────────────────────────────────────────────── | ||
| # Truncate for Discord | ||
| # ──────────────────────────────────────────────── | ||
| - name: Truncate message for Discord | ||
| id: truncate-discord | ||
| uses: 2428392/gh-truncate-string-action@b3ff790d21cf42af3ca7579146eedb93c8fb0757 # v1.4.1 | ||
| with: | ||
| maxLength: 2000 | ||
| stringToTruncate: | | ||
| ${{ steps.vars.outputs.announce }} | ||
|
|
||
| ${{ steps.vars.outputs.body_safe }} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MarkdownV2-escaped content sent to Discord
Discord uses a different markdown dialect: it only strips a leading
The fix is to produce two separate outputs from the # In the vars step:
echo "announce_plain=📢 Acode $TAG ($URL) was just Released 🎉${SUFFIX_PLAIN}!" >> $GITHUB_OUTPUT
{
echo "body_plain<<$DELIMITER"
printf '%s\n' "$INPUT_BODY"
echo "$DELIMITER"
} >> $GITHUB_OUTPUT
# In the Discord truncate step:
stringToTruncate: |
${{ steps.vars.outputs.announce_plain }}
${{ steps.vars.outputs.body_plain }} |
||
|
|
||
| # ──────────────────────────────────────────────── | ||
| # Discord notification | ||
| # ──────────────────────────────────────────────── | ||
| - name: Discord Webhook (Publishing) | ||
| uses: tsickert/discord-webhook@c840d45a03a323fbc3f7507ac7769dbd91bfb164 # v5.3.0 | ||
| with: | ||
| webhook-url: ${{ secrets.DISCORD_WEBHOOK_RELEASE_NOTES }} | ||
| content: ${{ steps.truncate-discord.outputs.string }} | ||
| continue-on-error: true | ||
|
|
||
| # ──────────────────────────────────────────────── | ||
| # Telegram notification — MarkdownV2 + no link preview | ||
| # ──────────────────────────────────────────────── | ||
| - name: Send to Telegram | ||
| uses: Salmansha08/telegram-github-action@17c9ce6b4210d2659dca29d34028b02fa29d70ad # or newer tag if available | ||
|
UnschooledGamer marked this conversation as resolved.
|
||
| with: | ||
| to: ${{ secrets.TELEGRAM_CHAT_ID }} | ||
| token: ${{ secrets.TELEGRAM_BOT_TOKEN }} | ||
| message: | | ||
| ${{ steps.vars.outputs.announce }} | ||
|
|
||
| ${{ steps.vars.outputs.body_safe }} | ||
| parse_mode: MarkdownV2 | ||
| disable_web_page_preview: true | ||
| # Only needed for topic-enabled supergroups/channels | ||
| message_thread_id: ${{ secrets.TELEGRAM_MESSAGE_THREAD_ID }} | ||
| continue-on-error: true | ||
|
UnschooledGamer marked this conversation as resolved.
|
||
Uh oh!
There was an error while loading. Please reload this page.