Update domains.yml

This commit is contained in:
William Harrison authored and GitHub committed 2023-05-01 11:34:28 +08:00
1 parent 07a8a7e240
commit 28a341a871
1 file changed
+32 -27
+32 -27
View File
@@ -29,38 +29,43 @@ jobs:
run: |
cd domains
for file in *.json; do
if [[ -f $file && ! -d $file ]]; then
while read -r line; do
record_type=$(echo "$line" | jq -r 'keys[]')
record_value=$(echo "$line" | jq -r '.[]')
if [[ "$record_type" =~ ^(A|AAAA)$ ]]; then
IFS=$'\n' read -r -a record_values <<< "$record_value"
for val in "${record_values[@]}"; do
ping_result=$(ping -c 1 "$val")
if [[ $? -eq 0 ]]; then
echo "PASS ${file%.json} $record_type $val"
else
echo "FAIL ${file%.json} $record_type $val"
fi
done
elif [[ "$record_type" == "CNAME" ]]; then
ping_result=$(ping -c 1 "$record_value")
if [[ $? -eq 0 ]]; then
echo "PASS ${file%.json} $record_type $record_value"
echo "PASS ${file%.json} $record_type $record_value" >> ../ping_results.txt
else
echo "FAIL ${file%.json} $record_type $record_value"
echo "FAIL ${file%.json} $record_type $record_value" >> ../ping_results.txt
fi
fi
done < <(jq -c '.records | to_entries[] | {"key": .key, "value": .value}' "$file")
fi
if [[ -f $file && ! -d $file ]]; then
while read -r line; do
record_type=$(echo "$line" | jq -r 'keys[]')
record_value=$(echo "$line" | jq -r '.[]')
if [[ "$record_type" =~ ^(A|AAAA)$ ]]; then
IFS=$'\n' read -r -a record_values <<< "$record_value"
for val in "${record_values[@]}"; do
ping_result=$(ping -c 1 "$val")
if [[ $? -eq 0 ]]; then
echo "PASS ${file%.json} $record_type $val"
echo "PASS ${file%.json} $record_type $val" >> ../ping_results.txt
else
echo "FAIL ${file%.json} $record_type $val"
echo "FAIL ${file%.json} $record_type $val" >> ../ping_results.txt
fi
done
elif [[ "$record_type" == "CNAME" ]]; then
ping_result=$(ping -c 1 "$record_value")
if [[ $? -eq 0 ]]; then
echo "PASS ${file%.json} $record_type $record_value"
echo "PASS ${file%.json} $record_type $record_value" >> ../ping_results.txt
else
echo "FAIL ${file%.json} $record_type $record_value"
echo "FAIL ${file%.json} $record_type $record_value" >> ../ping_results.txt
fi
fi
done < <(jq -c '.records | to_entries[] | {"key": .key, "value": .value}' "$file")
fi
done
- name: Push Data
run: |
git config --global user.email "bot@freesubdomains.org"
git config --global user.name "free-domains-bot"
git add ping_results.txt
git add ../ping_results.txt
git commit -m "Update Ping Results"
git push