Skip to content

Update Blocklist

Update Blocklist #233

Workflow file for this run

name: Update Blocklist
on:
workflow_dispatch:
schedule:
- cron: "0 */12 * * *"
env:
SOURCES: config/sources.txt
RAW_DIR: lists/_raw
OUTPUT: lists/merged.txt
permissions:
contents: write
actions: write
concurrency:
group: blocklist-update
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 1
- name: Setup Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.14"
cache: pip
- name: Install Dependencies
run: pip install -q .
- name: Get Cache Key
id: cache-key
run: echo "date=$(date -u +'%Y-%m-%d_%H%M')" >> $GITHUB_OUTPUT
- name: Restore Cache
id: cache-restore
uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: |
.cache
~/.cache/tldextract
key: blocklists-${{ steps.cache-key.outputs.date }}
restore-keys: blocklists-
- name: Fetch Sources
id: fetch
run: |
START=$(date +%s)
python -m scripts.downloader \
--sources "$SOURCES" \
--outdir "$RAW_DIR" \
--cache .cache \
--concurrency 10 \
--timeout 25
echo "time=$(($(date +%s) - START))s" >> $GITHUB_OUTPUT
echo "count=$(find "$RAW_DIR" -name '*.txt' | wc -l)" >> $GITHUB_OUTPUT
- name: Compile Sources
id: compile
run: |
START=$(date +%s)
python -m scripts.pipeline "$RAW_DIR" "$OUTPUT"
echo "time=$(($(date +%s) - START))s" >> $GITHUB_OUTPUT
- name: Calculate Stats
id: stats
run: |
RULES=$(wc -l < "$OUTPUT")
SIZE=$(du -h "$OUTPUT" | cut -f1)
echo "rules=$RULES" >> $GITHUB_OUTPUT
echo "size=$SIZE" >> $GITHUB_OUTPUT
- name: Validate Output
run: |
RULES=${{ steps.stats.outputs.rules }}
MIN=1000000
if [ "$RULES" -lt "$MIN" ]; then
echo "::error::Only $RULES rules (expected >$MIN)"
exit 1
fi
echo "Validation passed: $RULES rules"
- name: Publish Release
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0
with:
tag_name: latest
name: Merged Blocklist
body: |
## Merged Blocklist
| Stat | Value |
|------|-------|
| Rules | ${{ steps.stats.outputs.rules }} |
| Size | ${{ steps.stats.outputs.size }} |
| Sources | ${{ steps.fetch.outputs.count }} |
### Usage
Add to AdGuard Home → Filters → DNS Blocklists:
```
https://github.com/${{ github.repository }}/releases/download/latest/merged.txt
```
files: |
${{ env.OUTPUT }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Save Cache
uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
if: always() && steps.fetch.outcome == 'success'
with:
path: |
.cache
~/.cache/tldextract
key: blocklists-${{ steps.cache-key.outputs.date }}
- name: Cleanup Old Caches
if: success()
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh cache list --repo ${{ github.repository }} \
--key blocklists- \
--sort created_at \
--order desc \
--limit 100 \
--json key \
--jq '.[3:] | .[].key' | while read -r key; do
echo "Deleting cache: $key"
gh cache delete "$key" --repo ${{ github.repository }} || true
done
- name: Summary
if: always()
run: |
cat >> $GITHUB_STEP_SUMMARY << 'EOF'
## Build Summary
| Metric | Value |
|--------|-------|
| Rules | ${{ steps.stats.outputs.rules || 'N/A' }} |
| Size | ${{ steps.stats.outputs.size || 'N/A' }} |
| Sources | ${{ steps.fetch.outputs.count || 'N/A' }} |
| Fetch Time | ${{ steps.fetch.outputs.time || '?' }} |
| Compile Time | ${{ steps.compile.outputs.time || '?' }} |
| Cache | ${{ steps.cache-restore.outputs.cache-matched-key || 'New' }} |
EOF