-
Notifications
You must be signed in to change notification settings - Fork 6
194 lines (174 loc) · 5.85 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
name: Build
on:
push:
branches:
- main
paths-ignore:
- '**.md'
schedule:
- cron: '0 12 * * *'
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install PDM
uses: pdm-project/setup-pdm@v4
with:
python-version: '3.11'
cache: 'true'
- name: Install dependencies
run: pdm install
- name: Run tests
run: pdm run test
build:
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install PDM
uses: pdm-project/setup-pdm@v4
with:
python-version: '3.11'
cache: 'true'
- name: Set up Go
uses: actions/setup-go@v5
- name: Pull v2fly community domain list
uses: actions/checkout@v4
with:
repository: 'v2fly/domain-list-community'
path: 'domain-list-community'
- name: Pull Loyalsoldier's geosite tool
uses: actions/checkout@v4
with:
repository: 'Loyalsoldier/domain-list-custom'
path: 'tool_geosite'
- name: Install Loyalsoldier's geoip tool
run: go install github.com/Loyalsoldier/geoip@latest
- name: Build rulesets
run: |
pdm run build
cp source/personal/*.js dists/personal/
- 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: Build Geosite DB
run: |
cd tool_geosite
go run ./ --datapath=../dists/geosite --outputpath=../dists --exportlists="" --togfwlist=""
- name: Build 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"]
}
},
{
"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"
}
}
],
"output": [
{
"type": "v2rayGeoIPDat",
"action": "output",
"args": {
"outputName": "geoip.dat",
"outputDir": "./dists"
}
},
{
"type": "maxmindMMDB",
"action": "output",
"args": {
"outputName": "geoip.mmdb",
"outputDir": "./dists",
"overwriteList": [
"cn",
"private"
]
}
}
]
}
EOF
geoip convert -c config.json
- name: Remove tmp files
run: |
rm -rf dists/geosite
rm dists/gfwlist.txt
- name: Build homepage
run: |
python build_homepage.py
cat <<EOF > dists/_headers
/*
X-Robots-Tag: noindex
/
! X-Robots-Tag
EOF
cat <<EOF > dists/404.html
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<title>404 - xkww3n's Rules</title>
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css">
</head>
<body>
<main>
<h1>xkww3n's Rules</h1>
<p>由 <a href="https://www.xkww3n.cyou">xkww3n</a> 维护的,面向多个代理软件的规则集</p>
<p>支持: Surge、Clash (Premium / Meta)、Stash、Choc、Quantumult (X)、Loon、Shadowrocket、LanceX 等</p>
<p>
项目源代码托管于 <a href="https://github.com/xkww3n/Rules/">GitHub</a>,
以 <a href="https://github.com/xkww3n/Rules/blob/main/LICENSE" target="_blank">MIT</a> 协议授权
</p>
<hr>
<p>资源不存在</p>
</main>
</body>
</html>
EOF
- name: Publish to Cloudflare Pages
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: 2e54d1245681bc04eaa33ed5d68bdfa7
command: pages deploy dists --project-name=xkww3n-rules