From 28a341a871d669cfc59f2f91b53eead51dfe3d3d Mon Sep 17 00:00:00 2001 From: William Harrison Date: Mon, 1 May 2023 11:34:28 +0800 Subject: [PATCH] Update domains.yml --- .github/workflows/domains.yml | 59 +++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/.github/workflows/domains.yml b/.github/workflows/domains.yml index d6ae48f..8514f1d 100644 --- a/.github/workflows/domains.yml +++ b/.github/workflows/domains.yml @@ -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