Update Blocklist #5116
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" "$DOMAIN_URL" | |
curl --insecure -m 300 -o "ipaddress_isp" "$IP_URL" | |
curl --insecure -m 300 -o "situs_judi.txt" "$SITUS_JUDI" | |
# Split large files into 50MB chunks | |
maxsize=52428800 | |
for file in domains ipaddress_isp situs_judi.txt; do | |
if [ -f "$file" ] && [ $(stat -c%s "$file") -gt $maxsize ]; then | |
split -b 50M "$file" "${file}_part_" | |
rm "$file" | |
fi | |
done | |
# Count entries | |
domain_count=$(grep -chE '.' domains_part_* 2>/dev/null || grep -cE '.' domains 2>/dev/null || echo 0) | |
ip_count=$(grep -chE '.' ipaddress_isp_part_* 2>/dev/null || grep -cE '.' ipaddress_isp 2>/dev/null || echo 0) | |
judi_count=$(grep -chE '.' situs_judi.txt_part_* 2>/dev/null || grep -cE '.' situs_judi.txt 2>/dev/null || echo 0) | |
# 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 block in README.md | |
tmpfile=$(mktemp) | |
awk '/<!-- SUMMARY:START -->/,/<!-- SUMMARY:END -->/ {next} {print}' README.md > "$tmpfile" | |
echo "$summary" >> "$tmpfile" | |
mv "$tmpfile" README.md | |
# Git operations | |
git config user.name "skiddle-bot" | |
git config user.email "[email protected]" | |
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 |