Update Blocklist #6789
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: | |
schedule: | |
- cron: '0 * * * *' # Every hour | |
workflow_dispatch: | |
jobs: | |
update-blocklist: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.head_ref }} | |
token: ${{ secrets.BOT_GITHUB_TOKEN || github.token }} | |
- name: Setup WireGuard | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y wireguard resolvconf | |
echo "${{ secrets.WIREGUARD_CONFIG }}" > wg0.conf | |
sudo mv wg0.conf /etc/wireguard/wg0.conf | |
sudo wg-quick up wg0 | |
shell: bash | |
- name: Download and Update Blocklist | |
run: | | |
set -e | |
now=$(date +"%Y-%m-%d %H:%M:%S") | |
# Download source files | |
curl --insecure -m 300 -o "domains.txt" "$DOMAIN_URL" | |
curl --insecure -m 300 -o "ipaddress_isp.txt" "$IP_URL" | |
curl --insecure -m 300 -o "situs_judi.txt" "$SITUS_JUDI" | |
# Count entries | |
domain_count=$(grep -cE '.' domains.txt 2>/dev/null || echo 0) | |
ip_count=$(grep -cE '.' ipaddress_isp.txt 2>/dev/null || echo 0) | |
judi_count=$(grep -cE '.' situs_judi.txt 2>/dev/null || echo 0) | |
# Split large files into 50MB chunks | |
maxsize=52428800 | |
for file in domains.txt ipaddress_isp.txt situs_judi.txt; do | |
if [ -f "$file" ] && [ $(stat -c%s "$file") -gt $maxsize ]; then | |
base="${file%.txt}" | |
split -b 50M -d -a 3 "$file" "${base}_" && rm "$file" | |
i=1 | |
for part in ${base}_???; do | |
mv "$part" "${base}_$(printf "%03d" $i).txt" | |
i=$((i + 1)) | |
done | |
fi | |
done | |
# Prepare summary | |
summary=$(cat <<EOF | |
<!-- SUMMARY:START --> | |
### 🧾 Blocklist Summary (Last Updated: $now) | |
| List | Entries | | |
|--------------|---------| | |
| Domains | $domain_count | | |
| IP Address | $ip_count | | |
| Situs Judi | $judi_count | | |
<!-- SUMMARY:END --> | |
EOF | |
) | |
# Replace summary in README.md between the markers | |
awk -v new_block="$summary" ' | |
BEGIN { found=0 } | |
{ | |
if ($0 ~ /<!-- SUMMARY:START -->/) { | |
print new_block | |
found=1 | |
skip=1 | |
next | |
} | |
if ($0 ~ /<!-- SUMMARY:END -->/) { | |
skip=0 | |
next | |
} | |
if (!skip) print $0 | |
}' README.md > README.tmp && mv README.tmp README.md | |
# Git operations | |
git config user.name "skiddle-bot" | |
git config user.email "165562787+skiddle-bot@users.noreply.github.com" | |
git add . | |
git commit -m "Updated on $now" || echo "No changes to commit" | |
git rebase | |
git push -u origin main | |
shell: bash | |
env: | |
DOMAIN_URL: ${{ secrets.SOURCE_URL }} | |
IP_URL: ${{ secrets.SOURCE_URL2 }} | |
SITUS_JUDI: ${{ secrets.SITUS_JUDI }} | |
- name: Kill WireGuard | |
run: | | |
sudo wg-quick down wg0 | |
shell: bash | |
- name: Notify via Discord (Success) | |
if: success() | |
run: | | |
curl -H "Content-Type: application/json" \ | |
-X POST -d '{ | |
"embeds": [{ | |
"title": "✅ Blocklist Update Successful", | |
"description": "The blocklist was updated and committed successfully.", | |
"color": 3066993, | |
"fields": [ | |
{"name": "Repository", "value": "${{ github.repository }}", "inline": true}, | |
{"name": "Time", "value": "'"$(date +"%Y-%m-%d %H:%M:%S")"'", "inline": true} | |
], | |
"footer": {"text": "Skiddle Bot | GitHub Actions"} | |
}] | |
}' ${{ secrets.DISCORD_WEBHOOK }} | |
shell: bash | |
- name: Notify via Discord (Failure) | |
if: failure() | |
run: | | |
curl -H "Content-Type: application/json" \ | |
-X POST -d '{ | |
"embeds": [{ | |
"title": "❌ Blocklist Update Failed", | |
"description": "An error occurred during the workflow execution.", | |
"color": 15158332, | |
"fields": [ | |
{"name": "Repository", "value": "${{ github.repository }}", "inline": true}, | |
{"name": "Time", "value": "'"$(date +"%Y-%m-%d %H:%M:%S")"'", "inline": true} | |
], | |
"footer": {"text": "Skiddle Bot | GitHub Actions"} | |
}] | |
}' ${{ secrets.DISCORD_WEBHOOK }} | |
shell: bash |