DNS Weekly Update #76
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: DNS Weekly Update | |
on: | |
schedule: | |
- cron: '0 2 * * 0' # Runs weekly on Sunday at 2 AM UTC | |
jobs: | |
dns-check: | |
name: Remove domains without NS records | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set dynamic branch name | |
id: branch_name | |
run: echo "branch_name=dns-update-$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV | |
- uses: actions/checkout@v4 | |
- name: Create and switch to the new branch | |
run: | | |
git checkout -b ${{ env.branch_name }} | |
echo "Created and switched to branch ${{ env.branch_name }}" | |
- run: | | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com' | |
- name: Python setup | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.9 | |
cache: 'pip' | |
- name: Install Requirements | |
run: pip install -r requirements.txt | |
- name: Check if list includes domains without NS records | |
run: | | |
cd scripts | |
python3 dnscheck.py | |
- name: Check for changes | |
id: check_changes | |
run: | | |
if [[ `git status --porcelain pihole-google.txt` ]]; then | |
echo "Domains found without NS records" | |
echo "changes_detected=true" >> $GITHUB_ENV | |
else | |
echo "No domains without NS records found" | |
echo "changes_detected=false" >> $GITHUB_ENV | |
fi | |
- name: Commit updated pihole-google.txt | |
if: env.changes_detected == 'true' | |
run: | | |
git add pihole-google.txt | |
git commit -am "Remove domains without NS records" | |
git push origin ${{ env.branch_name }} | |
- name: Install GitHub CLI (gh) | |
if: env.changes_detected == 'true' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y gh | |
- name: Create Pull Request | |
if: env.changes_detected == 'true' | |
env: | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
run: | | |
gh pr create \ | |
--base master \ | |
--head ${{ env.branch_name }} \ | |
--title "Automated DNS Update: Remove domains without NS records" \ | |
--body "This PR contains the weekly updates to the DNS list by removing domains without NS records." |