-
Notifications
You must be signed in to change notification settings - Fork 734
142 lines (130 loc) · 5.21 KB
/
partial-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
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
name: Partial update
on:
push:
branches:
- adlist-maker
paths:
- '**.php'
- 'scripts/origin-files/base-dead-hosts.txt'
- 'scripts/origin-files/base-src-easylist.txt'
- 'scripts/origin-files/base-src-hosts.txt'
- 'scripts/origin-files/base-src-strict-hosts.txt'
- 'scripts/origin-files/whiterule-src-easylist.txt'
- 'scripts/origin-files/wildcard-src-easylist.txt'
jobs:
partial-build:
runs-on: ubuntu-latest
steps:
- name: Get source code from master
uses: actions/checkout@v4
with:
ref: master
path: master
- name: Get source code from adlist-maker
uses: actions/checkout@v4
with:
ref: adlist-maker
path: adlist-maker
- name: Build anti-AD lists
working-directory: adlist-maker
run: |
/bin/bash ./scripts/build-list.sh
- name: Commit anti-AD changes
run: |
mv -f ./adlist-maker/adblock-for-dnsmasq.conf ./master/
mv -f ./adlist-maker/anti-ad-* ./master/
cd ./master
git config user.email "[email protected]"
git config user.name "GitHub Action[bot]"
git add .
git commit -m "Auto renew anti-AD lists" -m "without upstream changes"
git push
sync:
if: github.repository == 'privacy-protection-tools/anti-AD'
needs: partial-build
runs-on: ubuntu-latest
steps:
- name: Get source code from master
uses: actions/checkout@v4
with:
ref: master
path: master
- name: Get source code from website
uses: actions/checkout@v4
with:
token: ${{ secrets.PERSON_TOKEN }}
repository: privacy-protection-tools/anti-ad.github.io
ref: master
path: website
- name: Install sing-box
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo curl -fsSL https://sing-box.app/gpg.key -o /etc/apt/keyrings/sagernet.asc
sudo chmod a+r /etc/apt/keyrings/sagernet.asc
echo "deb [arch=`dpkg --print-architecture` signed-by=/etc/apt/keyrings/sagernet.asc] https://deb.sagernet.org/ * *" | sudo tee /etc/apt/sources.list.d/sagernet.list > /dev/null
sudo apt-get update
sudo apt-get install sing-box
- name: Install mihomo
env:
DEBIAN_FRONTEND: noninteractive
run: |
case "$(uname -m)" in
'x86_64') ARCH='amd64' ;;
'x86' | 'i686' | 'i386') ARCH='386' ;;
'aarch64' | 'arm64') ARCH='arm64' ;;
'armv7l') ARCH='armv7' ;;
'riscv64') ARCH='riscv64' ;;
's390x') ARCH='s390x' ;;
*) ARCH='unknown' ;;
esac
echo "The architecture is: $ARCH"
[ "$ARCH" = 'unknown' ] || {
MIHOMO_VER=$(wget -q -O - 'https://github.com/MetaCubeX/mihomo/releases/download/Prerelease-Alpha/version.txt')
# e.g. alpha-3e966e8
MIHOMO_URL='https://github.com/MetaCubeX/mihomo/releases/download/Prerelease-Alpha/mihomo-linux-'$ARCH'-'$MIHOMO_VER'.deb'
# e.g. https://github.com/MetaCubeX/mihomo/releases/download/Prerelease-Alpha/mihomo-linux-amd64-alpha-3e966e8.deb
wget -q -O ./mihomo.deb "$MIHOMO_URL"
sudo apt-get install ./mihomo.deb
rm -f ./mihomo.deb
}
- name: Compile binary for sing-box/mihomo
working-directory: master
run: |
if [ "$(which sing-box 2>/dev/null)"x = 'x' ]; then
echo 'sing-box not available.'
else
echo 'Compiling sing-box rule-set...'
sing-box rule-set convert --type adguard ./anti-ad-adguard.txt --output ./anti-ad-sing-box.srs
sha256sum ./anti-ad-sing-box.srs
fi
if [ "$(which mihomo 2>/dev/null)"x = 'x' ]; then
echo 'mihomo not available.'
else
echo 'Compiling mihomo ruleset...'
mihomo convert-ruleset domain yaml ./anti-ad-clash.yaml ./anti-ad-mihomo.mrs
sha256sum ./anti-ad-mihomo.mrs
fi
- name: Update website files
run: |
cp -f ./master/anti-ad-easylist.txt ./website/docs/easylist.txt
cp -f ./master/anti-ad-easylist.txt.md5 ./website/docs/easylist.txt.md5
cp -f ./master/anti-ad-adguard.txt ./website/docs/adguard.txt
cp -f ./master/anti-ad-adguard.txt.md5 ./website/docs/adguard.txt.md5
cp -f ./master/adblock-for-dnsmasq.conf ./website/docs/dnsmasq.conf
cp -f ./master/adblock-for-dnsmasq.conf ./website/docs/anti-ad-for-dnsmasq.conf
cp -f ./master/anti-ad-smartdns.conf ./website/docs/anti-ad-for-smartdns.conf
cp -f ./master/anti-ad-surge.txt ./website/docs/surge.txt
cp -f ./master/anti-ad-surge2.txt ./website/docs/surge2.txt
cp -f ./master/anti-ad-clash.yaml ./website/docs/clash.yaml
cp -f ./master/anti-ad-domains.txt ./website/docs/domains.txt
[ -s './master/anti-ad-sing-box.srs' ] && cp -f ./master/anti-ad-sing-box.srs ./website/docs/anti-ad-sing-box.srs
[ -s './master/anti-ad-mihomo.mrs' ] && cp -f ./master/anti-ad-mihomo.mrs ./website/docs/mihomo.mrs
- name: Commit to website
working-directory: website
run: |
git config user.email "[email protected]"
git config user.name "GitHub Action[bot]"
git add .
git commit -m "Sync latest lists"
git push