-
Notifications
You must be signed in to change notification settings - Fork 257
65 lines (59 loc) · 1.84 KB
/
sync.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
name: Config Update
on:
push:
branches: [ main ]
workflow_dispatch:
schedule:
- cron: '0 12 * * *'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: "Setup sing-box"
env:
SING_BOX_DEB_URL: "https://github.com/SagerNet/sing-box/releases/download/v1.10.0-alpha.27/sing-box_1.10.0-alpha.27_linux_amd64.deb"
run: |
set -Eeuo pipefail
wget -O sing-box.deb $SING_BOX_DEB_URL
sudo dpkg -i sing-box.deb
- name: Set up Python3
uses: actions/setup-python@v2
with:
python-version: 3.x
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pandas requests pyyaml
- name: Download content
run: |
URL="https://raw.githubusercontent.com/AdguardTeam/AdguardFilters/master/BaseFilter/sections/adservers.txt"
OUTPUT_FILE="./rule/adservers.txt"
curl -L $URL -o $OUTPUT_FILE
if [ -f "$OUTPUT_FILE" ]; then
echo "Download successful: $OUTPUT_FILE"
else
echo "Download failed."
exit 1
fi
- name: Convert AdGuard DNS Filter to sing-box rule set
run: |
sing-box rule-set convert --type adguard --output ./rule/adservers.srs ./rule/adservers.txt
- name: Run script
run: python ../main.py
working-directory: ./rule/
- name: Commit and push config.json
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Action"
git add ./rule/*.json
git add ./rule/*.srs
git add ./rule/*.txt
# 检查是否有文件被修改
if git diff --staged --quiet; then
echo "No changes to commit"
exit 0
else
git commit -m "Update rules"
git push
fi