Skip to content

Update Telegram DC IP List #176

Update Telegram DC IP List

Update Telegram DC IP List #176

name: Update Telegram DC IP List
on:
schedule:
# 每天北京时间早上 6:00 运行 (UTC 22:00)
- cron: '0 22 * * *'
workflow_dispatch:
# 允许手动触发
permissions:
contents: write
jobs:
update-list:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Generate Rules
run: |
# 1. 准备目录
mkdir -p Surge
# 2. 定义文件路径
SURGE_FILE="Surge/telegram_dc_ip.conf"
# 3. 获取当前时间 (北京时间)
CURRENT_DATE=$(TZ='Asia/Shanghai' date '+%Y-%m-%d %H:%M:%S')
# 4. 写入头部注释
# Surge
echo "# Telegram Official DC List (Surge)" > $SURGE_FILE
echo "# Source: https://core.telegram.org/resources/cidr.txt" >> $SURGE_FILE
echo "# Updated: $CURRENT_DATE" >> $SURGE_FILE
echo "" >> $SURGE_FILE
# 5. 下载并分流处理数据
curl -sL https://core.telegram.org/resources/cidr.txt | while read line; do
# 跳过空行
if [ -z "$line" ]; then continue; fi
# --- 处理 Surge 格式 (带前缀和参数) ---
if [[ "$line" == *":"* ]]; then
echo "IP-CIDR6,$line,no-resolve" >> $SURGE_FILE
else
echo "IP-CIDR,$line,no-resolve" >> $SURGE_FILE
fi
done
# 6. 打印预览
echo "=== Surge File Preview ==="
head -n 6 $SURGE_FILE
- name: Commit and Push
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
# 添加文件
git add Surge/telegram_dc_ip.conf
# 检查是否有变化
if git diff --staged --quiet; then
echo "No changes detected. Skipping commit."
else
git commit -m "Auto-update Telegram DC lists: $(TZ='Asia/Shanghai' date '+%Y-%m-%d')"
git push
fi