Skip to content

Commit fb84ac8

Browse files
committed
Trigger telegram workflow on published event
1 parent 2f99acb commit fb84ac8

File tree

2 files changed

+40
-25
lines changed

2 files changed

+40
-25
lines changed

.github/workflows/publish.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Telegram
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
get-latest-release:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout repository
12+
uses: actions/checkout@v4
13+
14+
- name: Send APK links to Telegram
15+
env:
16+
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
17+
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
18+
VERSION: ${{ github.event.release.tag_name }}
19+
run: |
20+
repo_url=$(git remote get-url origin)
21+
username=$(echo "$repo_url" | sed -E 's#.*github.com[:/](.*)/(.*).git#\1#')
22+
repo_name=$(echo "$repo_url" | sed -E 's#.*github.com[:/](.*)/(.*).git#\2#')
23+
architectures=("arm64-v8a" "armeabi-v7a" "universal" "x86" "x86_64")
24+
NL="%0A"
25+
26+
MESSAGE="🚀 *New Release Available! $VERSION*$NL$NL"
27+
28+
MESSAGE+="${{ github.event.release.body }}$NL"
29+
30+
for arch in "${architectures[@]}"; do
31+
name="hviewer-$VERSION-$arch-release.apk"
32+
MESSAGE+="🔹 [$name](https://github.com/$username/$repo_name/releases/latest/download/$name)$NL"
33+
done
34+
35+
echo $MESSAGE
36+
37+
curl -X POST "https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendMessage" \
38+
-d "chat_id=$TELEGRAM_CHAT_ID" \
39+
-d "parse_mode=Markdown" \
40+
-d "text=$MESSAGE"

.github/workflows/release.yml

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -74,28 +74,3 @@ jobs:
7474
fail_on_unmatched_files: true
7575
make_latest: true
7676

77-
- name: Send APK links to Telegram
78-
env:
79-
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
80-
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
81-
VERSION: ${{ github.ref_name }}
82-
run: |
83-
repo_url=$(git remote get-url origin)
84-
username=$(echo "$repo_url" | sed -E 's#.*github.com[:/](.*)/(.*).git#\1#')
85-
repo_name=$(echo "$repo_url" | sed -E 's#.*github.com[:/](.*)/(.*).git#\2#')
86-
architectures=("arm64-v8a" "armeabi-v7a" "universal" "x86" "x86_64")
87-
NL="%0A"
88-
89-
MESSAGE="🚀 *New Release Available! $VERSION*$NL$NL"
90-
91-
for arch in "${architectures[@]}"; do
92-
name="hviewer-$VERSION-$arch-release.apk"
93-
MESSAGE+="🔹 [$name](https://github.com/$username/$repo_name/releases/latest/download/$name)$NL"
94-
done
95-
96-
echo $MESSAGE
97-
98-
curl -X POST "https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendMessage" \
99-
-d "chat_id=$TELEGRAM_CHAT_ID" \
100-
-d "parse_mode=Markdown" \
101-
-d "text=$MESSAGE"

0 commit comments

Comments
 (0)