|
1 | | -name: Notify Multiple Telegram Chats on GitHub Push |
2 | | -description: | |
3 | | - This GitHub Action sends a notification to multiple Telegram chats whenever there is a push to the main branch. |
4 | | - It uses the Telegram Bot API to send messages. |
| 1 | +name: Notify Telegram on GitHub Push |
| 2 | +description: 'Send notifications to Telegram groups (topics) and channel on push to main branch' |
5 | 3 | on: |
6 | 4 | push: |
7 | 5 | branches: |
|
11 | 9 | notify: |
12 | 10 | runs-on: ubuntu-latest |
13 | 11 | steps: |
14 | | - - name: Send commit message to multiple Telegram chats |
| 12 | + - name: Send notification to tgmShare group topic 5 |
15 | 13 | env: |
16 | 14 | BOT_TOKEN: ${{ secrets.BOT_TOKEN }} |
17 | | - CHAT_IDS: ${{ secrets.TELEGRAM_CHAT_IDS }} |
18 | 15 | run: | |
19 | | - echo "BOT_TOKEN: $BOT_TOKEN" |
20 | | - echo "CHAT_IDS: $CHAT_IDS" |
21 | | - IFS=',' read -ra IDS <<< "$CHAT_IDS" |
22 | | - for chat in "${IDS[@]}"; do |
23 | | - response=$(curl -s -X POST "https://api.telegram.org/bot${BOT_TOKEN}/sendMessage" \ |
24 | | - -d chat_id="$chat" \ |
25 | | - --data-urlencode "text= 📢 新资源增加啦! |
26 | | - 📝 提交内容: ${{ github.event.head_commit.message }} |
27 | | - 🔗 查看详情: https://github.com/${{ github.repository }} |
28 | | - 🔗 超过100T资料总站网站:https://doc.869hr.uk") |
29 | | - echo "Telegram response for chat_id $chat: $response" |
30 | | - done |
| 16 | + TEXT="📝 新增资源\n\n${{ github.event.head_commit.message }}\n\n🔗 超过100T资料总站网站:https://doc.869hr.uk\n📦 完整资源链接:https://t.me/dabaziyuan" |
| 17 | + curl -s -X POST "https://api.telegram.org/bot${BOT_TOKEN}/sendMessage" \ |
| 18 | + -d chat_id="-1002573762160" \ |
| 19 | + -d message_thread_id="5" \ |
| 20 | + -d parse_mode="Markdown" \ |
| 21 | + --data-urlencode "text=${TEXT}" |
31 | 22 |
|
| 23 | + - name: Send notification to tgmShareAI group topic 2 |
| 24 | + env: |
| 25 | + BOT_TOKEN: ${{ secrets.BOT_TOKEN }} |
| 26 | + run: | |
| 27 | + TEXT="📝 新增资源\n\n${{ github.event.head_commit.message }}\n\n🔗 超过100T资料总站网站:https://doc.869hr.uk\n📦 完整资源链接:https://t.me/dabaziyuan" |
| 28 | + curl -s -X POST "https://api.telegram.org/bot${BOT_TOKEN}/sendMessage" \ |
| 29 | + -d chat_id="-1003365897434" \ |
| 30 | + -d message_thread_id="2" \ |
| 31 | + -d parse_mode="Markdown" \ |
| 32 | + --data-urlencode "text=${TEXT}" |
| 33 | +
|
| 34 | + - name: Send full content to Telegram channel |
| 35 | + env: |
| 36 | + BOT_TOKEN: ${{ secrets.BOT_TOKEN }} |
| 37 | + CHANNEL_ID: ${{ secrets.TELEGRAM_CHANNEL_ID }} |
| 38 | + run: | |
| 39 | + if [ -n "$CHANNEL_ID" ]; then |
| 40 | + TEXT="📦 新增资源推送\n\n${{ github.event.head_commit.message }}\n\n🔗 超过100T资料总站网站:https://doc.869hr.uk\n📂 查看详情:${{ github.event.head_commit.url }}" |
| 41 | + curl -s -X POST "https://api.telegram.org/bot${BOT_TOKEN}/sendMessage" \ |
| 42 | + -d chat_id="$CHANNEL_ID" \ |
| 43 | + -d parse_mode="Markdown" \ |
| 44 | + --data-urlencode "text=${TEXT}" |
| 45 | + fi |
0 commit comments