fix a bug

This commit is contained in:
BROBIRD
2026-06-02 02:57:43 +08:00
parent 6ccb9ff145
commit 41076e58f7

View File

@@ -16,6 +16,7 @@ jobs:
uses: actions/checkout@v5
with:
fetch-depth: 0
ref: master
- name: Set up Python
uses: actions/setup-python@v6
@@ -82,16 +83,34 @@ jobs:
return 1
}
# 检查 YAML 文件是否有有效内容(排除 payload: 和空行/注释行)
has_yaml_content() {
local file=$1
local content_lines=$(sed '/^payload:$/d; /^#/d; /^$/d' "$file" | wc -l)
[ "$content_lines" -gt 0 ]
}
# 检查 LIST 文件是否有有效内容(排除注释和空行)
has_list_content() {
local file=$1
local content_lines=$(sed '/^#/d; /^$/d' "$file" | wc -l)
[ "$content_lines" -gt 0 ]
}
# 处理所有分离文件(包括生成的和已存在的)
for file in Clash/Providers/*_domain.yaml Clash/Providers/*_ip.yaml Clash/Providers/Ruleset/*_domain.yaml Clash/Providers/Ruleset/*_ip.yaml; do
if [ -f "$file" ]; then
filename=$(basename "$file")
if [[ "$filename" == *"_domain.yaml" ]]; then
base=$(basename "$file" _domain.yaml)
convert_file "domain" "yaml" "$file" "Clash/mrs/${base}_domain.mrs"
elif [[ "$filename" == *"_ip.yaml" ]]; then
base=$(basename "$file" _ip.yaml)
convert_file "ipcidr" "yaml" "$file" "Clash/mrs/${base}_ip.mrs"
if has_yaml_content "$file"; then
if [[ "$filename" == *"_domain.yaml" ]]; then
base=$(basename "$file" _domain.yaml)
convert_file "domain" "yaml" "$file" "Clash/mrs/${base}_domain.mrs"
elif [[ "$filename" == *"_ip.yaml" ]]; then
base=$(basename "$file" _ip.yaml)
convert_file "ipcidr" "yaml" "$file" "Clash/mrs/${base}_ip.mrs"
fi
else
echo "Skipping empty or invalid file: $file"
fi
fi
done
@@ -99,12 +118,16 @@ jobs:
for file in Clash/Ruleset/*_domain.list Clash/Ruleset/*_ip.list; do
if [ -f "$file" ]; then
filename=$(basename "$file")
if [[ "$filename" == *"_domain.list" ]]; then
base=$(basename "$file" _domain.list)
convert_file "domain" "text" "$file" "Clash/mrs/${base}_domain.mrs"
elif [[ "$filename" == *"_ip.list" ]]; then
base=$(basename "$file" _ip.list)
convert_file "ipcidr" "text" "$file" "Clash/mrs/${base}_ip.mrs"
if has_list_content "$file"; then
if [[ "$filename" == *"_domain.list" ]]; then
base=$(basename "$file" _domain.list)
convert_file "domain" "text" "$file" "Clash/mrs/${base}_domain.mrs"
elif [[ "$filename" == *"_ip.list" ]]; then
base=$(basename "$file" _ip.list)
convert_file "ipcidr" "text" "$file" "Clash/mrs/${base}_ip.mrs"
fi
else
echo "Skipping empty or invalid file: $file"
fi
fi
done