Skip to content

Commit 6521e74

Browse files
Automate removing domains without ns records
1 parent 325f988 commit 6521e74

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

.github/workflows/dns-check.yml

+7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ jobs:
77
continue-on-error: true
88
steps:
99
- uses: actions/checkout@v2
10+
- run: |
11+
git config --global user.name 'github-actions[bot]'
12+
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
1013
name: Python setup
1114
- uses: actions/setup-python@v2
1215
with:
@@ -17,3 +20,7 @@ jobs:
1720
run: |
1821
cd scripts
1922
python3 dnscheck.py
23+
- name: Commit updated pihole-google.txt
24+
run: |
25+
git add pihole-google.txt && git commit -am "Remove domains without NS records"
26+
git push

scripts/dnscheck.py

+7
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ def check_domain(domain):
1515

1616
def main():
1717
found_domains = 0
18+
domains_with_ns_records = []
1819

1920
with open("../pihole-google.txt") as f:
2021
for line in f:
@@ -23,6 +24,12 @@ def main():
2324
if check_domain(domain):
2425
print(f"Domain without NS records: {domain}")
2526
found_domains += 1
27+
else:
28+
domains_with_ns_records.append(line)
29+
30+
# Write remaining domains back to the file
31+
with open("../pihole-google.txt", "w") as f:
32+
f.writelines(domains_with_ns_records)
2633

2734
if found_domains > 0:
2835
sys.exit(1)

0 commit comments

Comments
 (0)