Update Blocklist #164
This file contains hidden or 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: Update AdGuard Blocklist (main branch) | |
| on: | |
| workflow_dispatch: {} | |
| schedule: | |
| - cron: "17 3 * * *" # daily @ 03:17 UTC | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout main | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| ref: main | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Generate blocklist | |
| env: | |
| OUTPUT_FILE: adguard_blocklist.txt | |
| SOURCES_FILE: sources.txt | |
| ALLOWLIST_FILE: allowlist.txt | |
| EXTRAS_BLOCK_FILE: extras_block.txt | |
| ENABLE_SUBSUMPTION: "1" | |
| run: | | |
| set -e | |
| python convert_hosts.py | |
| echo "== Preview (head -n 20) ==" | |
| head -n 20 adguard_blocklist.txt | |
| RULES=$(grep -E '^\|\|.+\^$' adguard_blocklist.txt | wc -l || true) | |
| echo "Rule count: $RULES" | |
| - name: Commit if changed | |
| shell: bash | |
| run: | | |
| set -e | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| RULES=$(grep -E '^\|\|.+\^$' adguard_blocklist.txt | wc -l | awk '{print $1}') | |
| TS=$(date -u +'%Y-%m-%dT%H:%M:%SZ') | |
| if [[ -n "$(git status --porcelain adguard_blocklist.txt)" ]]; then | |
| git add adguard_blocklist.txt | |
| git commit -m "update blocklist (rules: ${RULES}) (${TS})" | |
| git push origin main | |
| else | |
| echo "No changes to commit." | |
| fi |