-
Notifications
You must be signed in to change notification settings - Fork 106
executable file
·105 lines (85 loc) · 3.03 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
name: Release
on:
schedule:
- cron: '0 0 * * Mon'
workflow_dispatch:
inputs:
force_update:
description: 'Force update'
required: false
default: 'false'
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.19
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"
if [[ ${{ github.event.inputs.force_update || 'false' }} == 'true' || $total -ne $old ]]; then
echo "SHOULD_UPDATE=true" >> $GITHUB_ENV
echo "Should Update"
fi
echo "TOTAL_DOMAINS=$total" >> $GITHUB_ENV
- name: Build .dat file
if: ${{ env.SHOULD_UPDATE }}
run: |
git clone https://github.com/v2fly/domain-list-community
rm -rf domain-list-community/data/*
mv output/ir_domains.txt domain-list-community/data/ir
mv output/other_domains.txt domain-list-community/data/other
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
if: ${{ env.SHOULD_UPDATE }}
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
- name: Calculate checksum
if: ${{ env.SHOULD_UPDATE }}
run: |
cd output
for file in *; do
sha256sum $file > $file.sha256
done
- name: Upload result as release
if: ${{ env.SHOULD_UPDATE }}
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 }}