Skip to content
Latchkey

Notify Telegram on GitHub Push workflow (mswnlz/edu-knowlege)

The Notify Telegram on GitHub Push workflow from mswnlz/edu-knowlege, explained and optimized by Latchkey.

C

CI health: C - fair

Point runs-on at Latchkey and get run de-duplication, job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.

Grade your own workflow free or run it on Latchkey →
Source: mswnlz/edu-knowlege.github/workflows/notify.ymlLicense MITView source

What it does

This is the Notify Telegram on GitHub Push workflow from the mswnlz/edu-knowlege repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
name: Notify Telegram on GitHub Push
description: 'Send notifications to Telegram channel only (groups are notified by Skills script)'
on:
  push:
    branches:
      - main

jobs:
  notify:
    runs-on: ubuntu-latest
    steps:
      - name: Send to channel
        env:
          BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
          CHANNEL_ID: ${{ secrets.TELEGRAM_CHANNEL_ID }}
        run: |
          if [ -n "$CHANNEL_ID" ]; then
            # 生成当前年月的网站页面链接(格式:YYYYMM)
            CURRENT_MONTH=$(date +'%Y%m')
            WEBSITE_URL="https://doc.869hr.uk/edu-knowlege/${CURRENT_MONTH}"
            
            TEXT=$'📦 新增资源推送\n\n${{ github.event.head_commit.message }}\n\n🔗 查看详情:'${WEBSITE_URL}$'\n🌐 资料总站:https://doc.869hr.uk\n📦 资料频道:https://t.me/dabaziyuan'
            curl -s -X POST "https://api.telegram.org/bot${BOT_TOKEN}/sendMessage" \
              -d chat_id="$CHANNEL_ID" \
              --data-urlencode "text=${TEXT}"
          fi

The same workflow, on Latchkey

Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.

name: Notify Telegram on GitHub Push
description: 'Send notifications to Telegram channel only (groups are notified by Skills script)'
on:
  push:
    branches:
      - main
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  notify:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
      - name: Send to channel
        env:
          BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
          CHANNEL_ID: ${{ secrets.TELEGRAM_CHANNEL_ID }}
        run: |
          if [ -n "$CHANNEL_ID" ]; then
            # 生成当前年月的网站页面链接(格式:YYYYMM)
            CURRENT_MONTH=$(date +'%Y%m')
            WEBSITE_URL="https://doc.869hr.uk/edu-knowlege/${CURRENT_MONTH}"
            
            TEXT=$'📦 新增资源推送\n\n${{ github.event.head_commit.message }}\n\n🔗 查看详情:'${WEBSITE_URL}$'\n🌐 资料总站:https://doc.869hr.uk\n📦 资料频道:https://t.me/dabaziyuan'
            curl -s -X POST "https://api.telegram.org/bot${BOT_TOKEN}/sendMessage" \
              -d chat_id="$CHANNEL_ID" \
              --data-urlencode "text=${TEXT}"
          fi
 

What changed

What Latchkey heals here

This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:

This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.