-
Notifications
You must be signed in to change notification settings - Fork 37
85 lines (67 loc) · 2.46 KB
/
go.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
name: Update uBlacklist subscription weekly
on:
schedule:
- cron: "0 0 * * 0"
push:
branches: [ main ]
workflow_dispatch:
jobs:
build:
name: Build
runs-on: ubuntu-latest
#if: github.event.repository.owner.id == github.event.sender.id
steps:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '>=1.17.0'
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
submodules: true
- name: Merge txt
run: |
# 预处理一些数据
cp source/gyli/Blocklist/BLOCKLIST_uBlacklist source/gyli/Blocklist/blocklist.txt
rm uBlacklist.txt
rm uBlocklist.txt
rm tools/uBlacklist_backup.txt
rm source/gyli/Blocklist/blocklist.txt
rm source/Paxxs/Google-Blocklist/data -rf
rm source/laylavish/uBlockOrigin-HUGE-AI-Blocklist/additional_list_nuclear.txt
rm source/laylavish/uBlockOrigin-HUGE-AI-Blocklist/list.txt
rm source/laylavish/uBlockOrigin-HUGE-AI-Blocklist/list_uBlacklist_nuclear.txt
rm source/laylavish/uBlockOrigin-HUGE-AI-Blocklist/noai_hosts.txt
mv reverse_url.txt tools/reverse_url
# 合并所有列表
find . -type f -name "*.txt" -exec sh -c 'cat "$0"; echo' {} \; > tools/uBlacklist
# Issue # 48
sed -i '/^http:\/\//d' source/zweie/some-rules-for-ublacklist/Annoyingbastard.txt
cd tools
mv uBlacklist uBlacklist.txt
go run main.go
cat -s uBlacklist.txt | sed '/^[[:space:]]*$/d'
mv uBlacklist.txt ../uBlacklist.txt -f
cd ..
# 删除以 # 开头的行
sed -i '/^#/d' uBlacklist.txt
# 删除以 ! 开头的行
sed -i '/^!/d' uBlacklist.txt
cat tools/reverse_url >> uBlacklist.txt
# 添加时间
sed -i "1i\! Update weekly at $(TZ=UTC-8 date +'%Y-%m-%d %T %z')" uBlacklist.txt
# 去除空行
sed -i '/^$/d' uBlacklist.txt
ln -s uBlacklist.txt uBlocklist.txt
# 获取当前时间存入环境变量
echo "CURRENT_TIME=$(TZ=UTC-8 date +'%Y-%m-%d %T %z')" >> $GITHUB_ENV
- name: Commit files
uses: EndBug/add-and-commit@v9
with:
message: "ci(build): update weekly at ${{ env.CURRENT_TIME }}"
committer_name: 'github-actions[bot]'
committer_email: 'github-actions[bot]@users.noreply.github.com'
add: |
'uBlacklist.txt'
'tools/uBlacklist_backup.txt'