-
Notifications
You must be signed in to change notification settings - Fork 6
174 lines (172 loc) · 5.39 KB
/
main.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
name: Generate
on:
push:
branches:
- main
paths-ignore:
- '**.md'
schedule:
- cron: '0 12 * * *'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
- name: Setup environment
run: pip install -r requirements.txt
- name: Set up Go
uses: actions/setup-go@v4
- name: Pull v2fly community domain list
uses: actions/checkout@v3
with:
repository: 'v2fly/domain-list-community'
path: 'domain-list-community'
- name: Pull Loyalsoldier's geosite tool
uses: actions/checkout@v3
with:
repository: 'Loyalsoldier/domain-list-custom'
path: 'tool_geosite'
- name: Install Loyalsoldier's geoip tool
run: go install -v github.com/Loyalsoldier/geoip@latest
- name: Pull sing-geoip tool
uses: actions/checkout@v3
with:
repository: 'xkww3n/sing-geoip'
path: 'tool_sing-geoip'
- name: Pull sing-geosite tool
uses: actions/checkout@v3
with:
repository: 'xkww3n/sing-geosite'
path: 'tool_sing-geosite'
- name: Generate rules
run: python generate.py
- name: Download MaxMind GeoLite2 Country DB
env:
MAXMIND_KEY: ${{ secrets.MAXMIND_KEY }}
run: |
wget -O ./GeoLite2-Country.tar.gz "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country&license_key=${MAXMIND_KEY}&suffix=tar.gz"
tar xzvf ./GeoLite2-Country.tar.gz
cp ./GeoLite2-Country_*/GeoLite2-Country.mmdb ./
- name: Generate Geosite DB
run: |
cd tool_geosite
go run ./ --datapath=../dists/geosite --outputpath=../dists --exportlists="" --togfwlist=""
- name: Generate GeoIP DB
run: |
cat <<EOF > config.json
{
"input": [
{
"type": "private",
"action": "add"
},
{
"type": "maxmindMMDB",
"action": "add",
"args": {
"uri": "./GeoLite2-Country.mmdb"
}
},
{
"type": "cutter",
"action": "remove",
"args": {
"wantedList": ["cn"],
"onlyIPType": "ipv4"
}
},
{
"type": "text",
"action": "add",
"args": {
"name": "cn",
"uri": "./dists/text/domestic_ip.txt",
"onlyIPType": "ipv4"
}
},
{
"type": "text",
"action": "add",
"args": {
"name": "cn",
"uri": "./dists/text/domestic_ip6.txt",
"onlyIPType": "ipv6"
}
},
{
"type": "text",
"action": "add",
"args": {
"name": "telegram",
"uri": "https://core.telegram.org/resources/cidr.txt"
}
},
{
"type": "clashRuleSetClassical",
"action": "add",
"args": {
"name": "apns",
"uri": "./dists/yaml/apns.yaml"
}
}
],
"output": [
{
"type": "v2rayGeoIPDat",
"action": "output",
"args": {
"outputName": "geoip.dat",
"outputDir": "./dists"
}
},
{
"type": "maxmindMMDB",
"action": "output",
"args": {
"outputName": "geoip.mmdb",
"outputDir": "./dists",
"overwriteList": [
"cn",
"private",
"telegram",
"apns"
]
}
}
]
}
EOF
geoip -c config.json
- name: Generate sing-box Geosite DB
run: |
cp dists/geosite.dat tool_sing-geosite/
cd tool_sing-geosite
go run .
cp geosite.db ../dists/
- name: Generate sing-box GeoIP DB
run: |
cp dists/geoip.mmdb tool_sing-geoip/
cd tool_sing-geoip
go run .
cp geoip.db ../dists/
- name: Remove tmp files
run: |
rm -rf dists/geosite
rm dists/gfwlist.txt
- name: Generate home page
run: python generate_homepage.py
- name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: 2e54d1245681bc04eaa33ed5d68bdfa7
projectName: xkww3n-rules
directory: ./dists
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
wranglerVersion: '3'