-
Notifications
You must be signed in to change notification settings - Fork 106
executable file
·109 lines (88 loc) · 3.28 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
name: Release
on:
schedule:
- cron: '0 0 * * Mon'
workflow_dispatch:
jobs:
crawl:
name: Crawl Domains
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10.6'
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: 1.21
cache: false
- name: Env
run: |
echo "TAG_NAME=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV
echo "RELEASE_NAME=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV
- name: Install dependencies
run: |
python -m pip install --upgrade pip
sudo apt update
sudo apt install libxml2-dev libxslt-dev -y
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Run python program
run: |
python src/main.py
- name: Check result files
run: |
total=$(wc -l output/domains.txt | awk 'END {print $1}')
old=$(curl -sSL --connect-timeout 5 -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/bootmortis/iran-hosted-domains/releases/latest | grep "body" | cut -d\" -f4 | cut -d " " -f1)
echo "total $total"
echo "old $old"
echo "TOTAL_DOMAINS=$total" >> $GITHUB_ENV
- name: Build .dat file
run: |
git clone https://github.com/v2fly/domain-list-community
rm -rf domain-list-community/data/*
python3 src/data/custom_domains.py | jq -r '.proxy | join("\n")' > domain-list-community/data/proxy
mv output/ir_domains.txt domain-list-community/data/ir
mv output/other_domains.txt domain-list-community/data/other
cp src/data/tld_ir.txt domain-list-community/data/tld-ir
cp src/data/all.txt domain-list-community/data/all
mv output/ads.txt domain-list-community/data/ads
cd domain-list-community
go run ./ --outputdir=../output
cd ../output
mv dlc.dat iran.dat
- name: Build sing-box .db file
run: |
git clone https://github.com/bootmortis/sing-geosite
cp output/iran.dat sing-geosite/data/iran.dat
cd sing-geosite
go run -v .
mv iran-geosite.db ../output/iran-geosite.db
cd rule-set
for file in *; do
sha256sum $file > $file.sha256
done
- name: Calculate checksum
run: |
cd output
for file in *; do
sha256sum $file > $file.sha256
done
- name: Upload singbox-geosite result as release
uses: ncipollo/release-action@v1
with:
artifacts: "sing-geosite/rule-set/*.*"
repo: sing-geosite
body: "${{ env.TOTAL_DOMAINS }} Domains"
token: ${{ secrets.SINGBOX_REPO_TOKEN }}
tag: ${{ env.TAG_NAME }}
name: ${{ env.RELEASE_NAME }}
- name: Upload iran-hosted result as release
uses: ncipollo/release-action@v1
with:
artifacts: "output/*.*"
body: "${{ env.TOTAL_DOMAINS }} Domains"
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ env.TAG_NAME }}
name: ${{ env.RELEASE_NAME }}