Files
bypass/.gitea/workflows/sync_raw_file.yml
yuanzhen869 deb7f78e3f
All checks were successful
SyncRawFile / sync_files (push) Successful in 34s
更新 .gitea/workflows/sync_raw_file.yml
2025-01-02 06:26:37 +00:00

70 lines
2.4 KiB
YAML

name: SyncRawFile
on:
push:
paths:
- .gitea/workflows/sync_raw_file.yml # 仅在该文件被修改时触发
schedule:
- cron: "0 */6 * * *" # 每小时执行一次
jobs:
sync_files:
runs-on: ubuntu-latest
steps:
- name: Clone Gitea repository
uses: actions/checkout@v3 # 使用最新版本的 checkout
- name: Define file types and download
run: |
# 定义文件目录和平台类型列表
directories=("Lan" "Apple" "Steam" "SteamCN" "Xbox" "OpenAI" "Gemini" "Claude" "China" "Proxy" "TikTok" "ChinaIPs")
# 平台类型和扩展名的映射
declare -A platform_extensions
platform_extensions=(
["Surge"]="list"
["Clash"]="list"
["Loon"]="list"
["QuantumultX"]="list"
["Shadowrocket"]="list"
)
# 循环遍历每个平台
for platform_type in "${!platform_extensions[@]}"; do
# 为每个平台类型创建对应目录
save_dir="./rule/${platform_type}"
# 检查并删除已存在的目录
if [ -d "$save_dir" ]; then
rm -rf "$save_dir" # 删除目录及其内容
fi
# 重新创建目录
mkdir -p "$save_dir"
# 获取当前平台类型的扩展名
filetype=${platform_extensions[$platform_type]}
# 循环遍历每个目录,下载对应平台下的文件
for directory in "${directories[@]}"; do
# 构建文件 URL
url="https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/${platform_type}/${directory}/${directory}.${filetype}"
# 使用 curl 下载文件并保存到动态路径
curl -o "$save_dir/${directory}.${filetype}" "$url"
done
done
- name: Commit and push changes to Gitea
run: |
# 设置 Git 配置信息
git config --global user.name "yuanzhen869"
git config --global user.email "yuanzhen869@gmail.com"
# 确保目录和文件已经更新
git add . # 添加所有更改的文件
# 提交更改
git commit -m "Sync files from GitHub raw" || echo "No changes to commit"
# 推送更改到 Gitea 仓库
git push origin main