-
Notifications
You must be signed in to change notification settings - Fork 0
144 lines (125 loc) · 6.18 KB
/
adrules.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
name: 5whys-Ad-list-processing
on:
workflow_dispatch:
watch:
types: [started]
schedule:
- cron: 21 */3 * * *
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go 1.x.y
uses: actions/setup-go@v3
with:
go-version: 1.19
check-latest: true
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '12.x'
- run: npm install
- name: Install hostlist-complier
run: npm i -g @adguard/hostlist-compiler
- name: Set folder condition, variables and timezone
run: |
sudo cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
echo "RELEASE_NAME=Released on $(date +%Y%m%d%H%M)" >> $GITHUB_ENV
echo "TAG_NAME=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV
rm -f ./out*.txt
- name: Run main.go
run: |
go run main.go "./setting/super_rules.txt" out_super.txt "./setting/custom.txt"
go run main.go "./setting/full_rules.txt" out_full.txt "./setting/custom.txt"
go run main.go "./setting/medium_rules.txt" out_med.txt "./setting/custom.txt"
go run main.go "./setting/min_rules.txt" out_min.txt "./setting/custom.txt"
- name: Create output_super.txt
run: |
line=$(wc -l < out_super.txt)
echo "# Title: 5whys SUPER block Adguard Home Rules List (Use with a lot of false rejects)" > output_super.txt
echo "# Verison: $(date +%Y%m%d%H%M)" >> output_super.txt
echo "# Expires: around 1 day" >> output_super.txt
echo "# Total number of rules = $line" >> output_super.txt
echo "# Below are the links of the adblock rules" >> output_super.txt
while IFS= read -r line; do echo "# $line" >> output_super.txt; done < "./setting/super_rules.txt"
echo "####################################################################################" >> output_super.txt
cat out_super.txt >> output_super.txt
echo "####################################################################################" >> output_super.txt
- name: Create output_full.txt
run: |
line=$(wc -l < out_full.txt)
echo "# Title: 5whys Full block Adguard Home Rules List" > output_full.txt
echo "# Verison: $(date +%Y%m%d%H%M)" >> output_full.txt
echo "# Expires: around 1 day" >> output_full.txt
echo "# Total number of rules = $line" >> output_full.txt
echo "# Below are the links of the adblock rules" >> output_full.txt
while IFS= read -r line; do echo "# $line" >> output_full.txt; done < "./setting/full_rules.txt"
echo "####################################################################################" >> output_full.txt
cat out_full.txt >> output_full.txt
echo "####################################################################################" >> output_full.txt
- name: Create output_medium.txt
run: |
line=$(wc -l < out_med.txt)
echo "# Title: 5whys Medium Adguard Home Rules List" > output_medium.txt
echo "# Verison: $(date +%Y%m%d%H%M)" >> output_medium.txt
echo "# Expires: around 1 day" >> output_medium.txt
echo "# Total number of rules = $line" >> output_medium.txt
echo "# Below are the links of the adblock rules" >> output_medium.txt
while IFS= read -r line; do echo "# $line" >> output_medium.txt; done < "./setting/medium_rules.txt"
echo "####################################################################################" >> output_medium.txt
cat out_med.txt >> output_medium.txt
echo "####################################################################################" >> output_medium.txt
- name: Create output_min.txt
run: |
line=$(wc -l < out_min.txt)
echo "# Title: 5whys Min Adguard Home Rules List" > output_min.txt
echo "# Verison: $(date +%Y%m%d%H%M)" >> output_min.txt
echo "# Expires: around 1 day" >> output_min.txt
echo "# Total number of rules = $line" >> output_min.txt
echo "# Below are the links of the adblock rules" >> output_min.txt
while IFS= read -r line; do echo "# $line" >> output_min.txt; done < "./setting/min_rules.txt"
echo "####################################################################################" >> output_min.txt
cat out_min.txt >> output_min.txt
echo "####################################################################################" >> output_min.txt
- name: move output file
run: |
mkdir -p ./publish/
cp ./output*.txt ./publish/
cp ./output*.txt ./rules/
- name: Release and upload assets
uses: softprops/[email protected]
with:
name: ${{ env.RELEASE_NAME }}
tag_name: ${{ env.TAG_NAME }}
draft: false
prerelease: false
files: |
./publish/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Git push assets to "release" branch
run: |
cd publish || exit 1
git init
git config --local user.name "github-actions[bot]"
git config --local user.email "121651775+github-actions[bot]@users.noreply.github.com"
git checkout -b release
git add .
git commit -m "${{ env.RELEASE_NAME }}"
git remote add origin "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}"
git push -f -u origin release
- name: Purge jsdelivr CDN
run: |
cd publish || exit 1
for file in $(ls); do
curl -i "https://purge.jsdelivr.net/gh/${{ github.repository }}@release/${file}"
done
- name: Commit *.txt
run: |
echo `date +"%Y-%m-%d %H:%M:%S"` ZJC CKC >> ./rules/date.log
git config --global user.email ${{ secrets.EMAIL }}
git config --global user.name ${{ secrets.NAME }}
git add ./rules/output* ./rules/date.log
git commit -m "${{ env.RELEASE_NAME }}"
git push