test: use original code

This commit is contained in:
William Harrison authored and GitHub committed 2023-05-01 11:30:39 +08:00
1 parent 6dfdf5b90c
commit 29ca6d7ecb
1 file changed
+26 -27
+26 -27
View File
@@ -29,33 +29,32 @@ 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"
else
echo "FAIL ${file%.json} $record_type $record_value"
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"
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
done
- name: Push Data