-
Notifications
You must be signed in to change notification settings - Fork 35
50 lines (42 loc) · 1.61 KB
/
telegram-bot.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
name: Release Notification
on:
release:
types:
- publish
workflow_dispatch:
jobs:
notify-telegram:
name: Notify Telegram
runs-on: ubuntu-latest
steps:
- name: Get Latest Release Info
id: get_latest_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Use GitHub API to fetch the latest release
response=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
"https://api.github.com/repos/${{ github.repository }}/releases/latest")
# Parse the response to extract needed fields
RELEASE_TAG=$(echo "$response" | jq -r '.tag_name')
RELEASE_NAME=$(echo "$response" | jq -r '.name')
RELEASE_NOTES=$(echo "$response" | jq -r '.body')
RELEASE_URL=$(echo "$response" | jq -r '.html_url')
# Export as environment variables
echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_ENV
echo "RELEASE_NAME=$RELEASE_NAME" >> $GITHUB_ENV
echo "RELEASE_NOTES=$RELEASE_NOTES" >> $GITHUB_ENV
echo "RELEASE_URL=$RELEASE_URL" >> $GITHUB_ENV
- name: Send Telegram Message
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
format: markdown
message: |
🎉 *A new release is live!* 🎉
**Release Name:** ${{ env.RELEASE_NAME }}
**Tag:** ${{ env.RELEASE_TAG }}
**Release Notes:**
${{ env.RELEASE_NOTES }}
🔗 [View Release](${{ env.RELEASE_URL }})