Skip to content

Sync ASN.China.list

Sync ASN.China.list #7

name: Sync ASN.China.list
on:
schedule:
- cron: '0 10 * * *' # 每天 UTC 10:00(北京时间18:00)
workflow_dispatch: # 支持手动触发
jobs:
sync:
runs-on: ubuntu-24.04 # 明确指定运行环境
steps:
- name: Checkout Your Repository
uses: actions/checkout@v3
- name: Fetch ASN.China.list from Source
run: |
FILE_URL="https://raw.githubusercontent.com/missuo/ASN-China/refs/heads/main/ASN.China.list"
LOCAL_PATH="Common/ASN.China.list"
# 创建目录并尝试下载文件
mkdir -p $(dirname $LOCAL_PATH)
if ! curl -fSL $FILE_URL -o $LOCAL_PATH; then
echo "Error: Failed to download $FILE_URL"
exit 2
fi
- name: Commit and Push Changes
run: |
git config user.name "cngzsunny"
git config user.email "[email protected]"
# 使用 Personal Access Token (PAT) 进行推送
git remote set-url origin https://cngzsunny:${{ secrets.GH_TOKEN }}@github.com/cngzsunny/vpn_tool.git
# 检查是否有更改
if [ -n "$(git status --porcelain)" ]; then
git add Common/ASN.China.list
git commit -m "Daily sync of ASN.China.list"
git push
else
echo "No changes detected, skipping commit."
fi