mirror of
https://github.com/ACL4SSR/ACL4SSR.git
synced 2026-06-09 14:02:32 +00:00
fix a bug
This commit is contained in:
47
.github/workflows/update.yml
vendored
47
.github/workflows/update.yml
vendored
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user