Skip to content

The Block List Project - Fraud List (adguard) #261

The Block List Project - Fraud List (adguard)

The Block List Project - Fraud List (adguard) #261

Workflow file for this run

name: Check blocklist
on:
issues:
types:
- labeled
permissions:
contents: write
issues: write
jobs:
check-blocklist:
if: ${{ github.event.label.name == 'check blocklist' }}
runs-on: ubuntu-latest
timeout-minutes: 180
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: main
- name: Get date for caching
run: |
echo "DATE=$(date +%m%d)" >> $GITHUB_ENV
echo "MONTH=$(date +%m%Y)" >> $GITHUB_ENV
- name: Restore cached dependencies
id: restore-cache
uses: actions/cache/restore@v4
with:
path: |
tranco.tmp
*_blocklist.tmp
# Restore cache when:
# - cache matches today's date
# - blocklists_to_compare.txt has not changed
key: dependencies-${{ env.DATE }}-${{ hashFiles('data/blocklists_to_compare.txt') }}
- name: Restore cached dependencies (monthly)
id: restore-cache-monthly
uses: actions/cache/restore@v4
with:
path: |
~/.npm
dead_cache.tmp
# Restore cache once a month
key: dependencies-${{ env.MONTH }}
- name: Check blocklist
run: |
# On error
trap 'gh issue comment ${{ github.event.issue.number }} -b \
"An error occurred while checking the blocklist." \
&& gh issue edit ${{ github.event.issue.number }} \
--remove-label "check blocklist" --remove-label "checking" \
--add-label "errored"' ERR
# Add 'checking' label
gh issue edit ${{ github.event.issue.number }} \
--remove-label 'check blocklist' --add-label 'checking'
# Get URl of blocklist
url="$(grep 'http' <<< "${{ github.event.issue.body }}")"
# Generate report
bash scripts/check.sh "$url"
# Comment report and close issue
gh issue close ${{ github.event.issue.number }} -c \
"$(cat data/TEMPLATE.md)"
# Update issue title and label
title="$(mawk -F '*' '/Report for/ {print $2}' data/TEMPLATE.md)"
gh issue edit ${{ github.event.issue.number }} -t "$title" \
--remove-label 'checking' --add-label 'report generated'
env:
GH_TOKEN: ${{ github.token }}
- name: Cache dependencies
# Cache only if no cache restored
if: ${{ steps.restore-cache.outputs.cache-hit != 'true' }}
uses: actions/cache/save@v4
with:
path: |
tranco.tmp
*_blocklist.tmp
key: dependencies-${{ env.DATE }}-${{ hashFiles('data/blocklists_to_compare.txt') }}
- name: Cache dependencies (monthly)
if: ${{ steps.restore-cache-monthly.outputs.cache-hit != 'true' }}
uses: actions/cache/save@v4
with:
path: |
~/.npm
dead_cache.tmp
key: dependencies-${{ env.MONTH }}