Update Blocklist #804
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 Blocklist | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "15 */4 * * *" # Every 4 hours | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - ".github/workflows/*.yaml" | |
| jobs: | |
| update-blocklist: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Download blocklist | |
| run: | | |
| curl -sSL https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/pro.mini-onlydomains.txt -o pro-mini-onlydomains.txt | |
| curl -sSL https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/tif.mini-onlydomains.txt -o tif-mini-onlydomains.txt | |
| curl -sSL https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/tif.medium-onlydomains.txt -o tif.medium-onlydomains.txt | |
| curl -ssL https://raw.githubusercontent.com/hagezi/dns-blocklists/main/adblock/spam-tlds-adblock-aggressive.txt -o spam.tlds-aggressive.txt | |
| - name: Remove first x lines and clean spam-tlds-aggressive.txt | |
| run: | | |
| tail -n +12 pro-mini-onlydomains.txt > pro.mini-onlydomains.txt | |
| tail -n +12 tif-mini-onlydomains.txt > tif.mini-onlydomains.txt | |
| tail -n +12 tif.medium-onlydomains.txt > tif.onlydomains.txt | |
| tail -n +18 spam.tlds-aggressive.txt | sed 's/||//g; s/\^//g' > spam-tlds-aggressive.txt | |
| - name: Filter tif.mini-onlydomains.txt based on spam-tlds-aggressive.txt | |
| run: | | |
| # Extract TLDs from spam-tlds-aggressive.txt | |
| awk -F'.' '{print $NF}' spam-tlds-aggressive.txt | sort -u > spam_tlds.txt | |
| # Prepare a grep pattern to match lines ending with those TLDs | |
| pattern=$(awk '{print "\\." $1 "$"}' spam_tlds.txt | paste -sd'|' -) | |
| # Filter tif.mini-onlydomains.txt to remove lines matching the TLDs | |
| if [ -n "$pattern" ]; then | |
| grep -Ev "$pattern" tif.mini-onlydomains.txt > tif.filtered.txt | |
| mv tif.filtered.txt tif.mini-onlydomains.txt | |
| fi | |
| - name: Filter tif.onlydomains.txt based on spam-tlds-aggressive.txt | |
| run: | | |
| # Prepare a grep pattern to match lines ending with those TLDs (reuse spam_tlds.txt) | |
| pattern=$(awk '{print "\\." $1 "$"}' spam_tlds.txt | paste -sd'|' -) | |
| # Filter tif.onlydomains.txt to remove lines matching the TLDs | |
| if [ -n "$pattern" ]; then | |
| grep -Ev "$pattern" tif.onlydomains.txt > tif.onlydomains.filtered.txt | |
| mv tif.onlydomains.filtered.txt tif.onlydomains.txt | |
| fi | |
| - name: Commit and push changes | |
| run: | | |
| git config --local user.name "github-actions[bot]" | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git add pro.mini-onlydomains.txt tif.mini-onlydomains.txt tif.onlydomains.txt spam-tlds-aggressive.txt | |
| git commit -m "Update processed blocklists" | |
| git push | |
| # dispatch-auto: | |
| # needs: [update-blocklist] | |
| # runs-on: ubuntu-latest | |
| # steps: | |
| # - uses: actions/create-github-app-token@v2 | |
| # id: app-token | |
| # with: | |
| # # required | |
| # app-id: ${{ vars.TERRAFORM_APP_ID }} | |
| # private-key: ${{ secrets.PRIVATE_KEY }} | |
| # permission-contents: write | |
| # owner: ${{ github.repository_owner }} | |
| # repositories: | | |
| # ${{ vars.TERRAFORM_REPO_NAME }} | |
| # - name: Repository Dispatch | |
| # uses: peter-evans/repository-dispatch@v3 | |
| # with: | |
| # event-type: blocklist-updated | |
| # token: ${{ steps.app-token.outputs.token }} | |
| # repository: miljodir/${{ vars.TERRAFORM_REPO_NAME }} | |
| # client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}' |