Skip to content

Commit db5f18b

Browse files
Workflows: Reduce Geodata update frequency (#4369)
1 parent c81d8e4 commit db5f18b

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

.github/workflows/hourly-prepare.yml .github/workflows/scheduled-assets-update.yml

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Timely assets update
1+
name: Scheduled assets update
22

33
# NOTE: This Github Actions is required by other actions, for preparing other packaging assets in a
44
# routine manner, for example: GeoIP/GeoSite.
@@ -8,19 +8,20 @@ name: Timely assets update
88
on:
99
workflow_dispatch:
1010
schedule:
11-
# Update assets on every hour (xx:30)
12-
- cron: '30 * * * *'
11+
# Update GeoData on every day (22:30 UTC)
12+
- cron: '30 22 * * *'
1313
push:
1414
# Prevent triggering update request storm
1515
paths:
16-
- ".github/workflows/hourly-prepare.yml"
16+
- ".github/workflows/scheduled-assets-update.yml"
1717
pull_request:
1818
# Prevent triggering update request storm
1919
paths:
20-
- ".github/workflows/hourly-prepare.yml"
20+
- ".github/workflows/scheduled-assets-update.yml"
2121

2222
jobs:
2323
geodat:
24+
if: github.event.schedule == '30 22 * * *' || github.event_name == 'push'|| github.event_name == 'pull_request'
2425
runs-on: ubuntu-latest
2526
steps:
2627
- name: Restore Geodat Cache
@@ -38,18 +39,18 @@ jobs:
3839
max_attempts: 60
3940
command: |
4041
[ -d 'resources' ] || mkdir resources
41-
LIST=('v2ray-rules-dat geoip geoip' 'v2ray-rules-dat geosite geosite')
42+
LIST=('Loyalsoldier v2ray-rules-dat geoip geoip' 'Loyalsoldier v2ray-rules-dat geosite geosite')
4243
for i in "${LIST[@]}"
4344
do
44-
INFO=($(echo $i | awk 'BEGIN{FS=" ";OFS=" "} {print $1,$2,$3}'))
45-
FILE_NAME="${INFO[2]}.dat"
45+
INFO=($(echo $i | awk 'BEGIN{FS=" ";OFS=" "} {print $1,$2,$3,$4}'))
46+
FILE_NAME="${INFO[3]}.dat"
4647
echo -e "Verifying HASH key..."
47-
HASH="$(curl -sL "https://raw.githubusercontent.com/Loyalsoldier/${INFO[0]}/release/${INFO[1]}.dat.sha256sum" | awk -F ' ' '{print $1}')"
48+
HASH="$(curl -sL "https://raw.githubusercontent.com/${INFO[0]}/${INFO[1]}/release/${INFO[2]}.dat.sha256sum" | awk -F ' ' '{print $1}')"
4849
if [ -s "./resources/${FILE_NAME}" ] && [ "$(sha256sum "./resources/${FILE_NAME}" | awk -F ' ' '{print $1}')" == "${HASH}" ]; then
4950
continue
5051
else
51-
echo -e "Downloading https://raw.githubusercontent.com/Loyalsoldier/${INFO[0]}/release/${INFO[1]}.dat..."
52-
curl -L "https://raw.githubusercontent.com/Loyalsoldier/${INFO[0]}/release/${INFO[1]}.dat" -o ./resources/${FILE_NAME}
52+
echo -e "Downloading https://raw.githubusercontent.com/${INFO[0]}/${INFO[1]}/release/${INFO[2]}.dat..."
53+
curl -L "https://raw.githubusercontent.com/${INFO[0]}/${INFO[1]}/release/${INFO[2]}.dat" -o ./resources/${FILE_NAME}
5354
echo -e "Verifying HASH key..."
5455
[ "$(sha256sum "./resources/${FILE_NAME}" | awk -F ' ' '{print $1}')" == "${HASH}" ] || { echo -e "The HASH key of ${FILE_NAME} does not match cloud one."; exit 1; }
5556
echo "unhit=true" >> $GITHUB_OUTPUT

0 commit comments

Comments
 (0)