Create domains.yml

This commit is contained in:
William Harrison authored and GitHub committed 2023-05-01 11:08:59 +08:00
1 parent d31d03a203
commit 3fd8140da6
1 file changed
+61
+61
View File
@@ -0,0 +1,61 @@
name: Domains
on:
workflow_dispatch: {}
push:
branches: [main]
schedule:
- cron: "0 0 * * *"
jobs:
ping:
name: Ping
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Create ping_results.txt
run: touch domains/ping_results.txt
- name: Ping Domains
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
done
- name: Push Data
run: |
git config --global user.email "bot@freesubdomains.org"
git config --global user.name "free-domains-bot"
git add domains/ping_results.txt
git commit -m "Update Ping Results"
git push