Download and generate blocklists #6768
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: Download and generate blocklists | |
on: | |
schedule: # https://crontab.guru | |
- cron: '0 */3 * * *' # At minute 0 past every 3rd hour. | |
workflow_dispatch: | |
jobs: | |
download: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
ref: main | |
- name: Download blocklists | |
run: bash bash/download.sh | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 22.x | |
cache: 'npm' | |
- name: Install dependencies | |
run: npm ci | |
- name: Prepare templates | |
run: node scripts/prepare-templates.js | |
- name: Remove duplicates from templates | |
run: node scripts/remove-duplicates.js | |
- name: Remove domains that are on the whitelist | |
run: node scripts/whitelist.js | |
- name: Set valid encoding | |
run: node scripts/set-valid-encoding.js | |
- name: Count domains | |
run: node scripts/update-number-of-domains.js | |
- name: Generate No IP list | |
run: node scripts/generate/noip.js | |
- name: Generate 0.0.0.0 list | |
run: node scripts/generate/0.0.0.0.js | |
- name: Generate 127.0.0.1 list | |
run: node scripts/generate/127.0.0.1.js | |
- name: Generate AdGuard list | |
run: node scripts/generate/adguard.js | |
- name: Generate Dnsmasq list | |
run: node scripts/generate/dnsmasq.js | |
- name: Generate RPZ list | |
run: node scripts/generate/rpz.js | |
- name: Generate list for Unbound | |
run: node scripts/generate/unbound.js | |
- name: Lint | |
run: node scripts/lint.js | |
- name: Run git pull | |
run: git pull origin main | |
- name: Add files to staging | |
run: git add . | |
- name: Commit and push changes | |
run: | | |
git config user.name "Sefinek Actions" | |
git config user.email "sefinek.actions@gmail.com" | |
if [ -n "$(git status -s)" ]; then | |
MODIFIED_FILES=$(git diff --name-only HEAD | grep -v '^cache/') | |
FILE_COUNT=$(echo "$MODIFIED_FILES" | wc -l) | |
if [ "$FILE_COUNT" -gt 0 ]; then | |
git commit -am "Main blocklist update every 3h [$FILE_COUNT files] - $(date -u '+%Y-%m-%d %H:%M:%S UTC')" -m "$MODIFIED_FILES" | |
git push origin main | |
else | |
echo "Canceled. No files to commit after excluding cache/ files." | |
fi | |
else | |
echo "Canceled. No changes to commit." | |
fi |