-
Notifications
You must be signed in to change notification settings - Fork 2
73 lines (63 loc) · 1.95 KB
/
update.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
name: update-list
on:
pull_request:
push:
branches:
- main
schedule:
- cron: "0 */3 * * *" # UTC
jobs:
update-list:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Setup wget and download lists
run: |
rm -f ip-list.txt
rm -rf blocklist
mkdir blocklist
wget -i urltable -P blocklist/ --wait 7
- name: Process and merge IP lists
run: |
cd blocklist
for file in *; do
# Remove comments, leading/trailing whitespace, and empty lines
sed 's/#.*//; s/;.*//; s/^[[:space:]]*//; s/[[:space:]]*$//; /^$/d' "$file" >> temp_output
done
# Sort and remove duplicates
sort -u temp_output > ip-list.txt
cd ..
mv blocklist/ip-list.txt .
rm -rf blocklist
- name: Remove IPs from exclusion list
run: |
rm -f exclusion_list.txt
rm -rf exclusion
mkdir exclusion
wget -i urlexclusion -P exclusion/ --wait 7
cd exclusion
for file in *; do
# Remove comments, leading/trailing whitespace, and empty lines
sed 's/#.*//; s/;.*//; s/^[[:space:]]*//; s/[[:space:]]*$//; /^$/d' "$file" >> temp_output2
done
# Sort and remove duplicates
sort -u temp_output2 > exclusion_list.txt
cd ..
mv exclusion/exclusion_list.txt .
rm -rf exclusion
# Remove IP From Exclusion folder
if [ -f exclusion_list.txt ]; then
grep -vFf exclusion_list.txt ip-list.txt > temp_list.txt
mv temp_list.txt ip-list.txt
fi
- name: Validate IP addresses
run: |
# Validate IP address
sed -i '/^[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}$/!d' ip-list.txt
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Update IP list