forked from XTLS/Xray-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from XTLS/main
Build: Update GeoIP/GeoSite Cache per hour (XTLS#4247)
- Loading branch information
Showing
4 changed files
with
67 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: Timely assets update | ||
|
||
# NOTE: This Github Actions is required by other actions, for preparing other packaging assets in a | ||
# routine manner, for example: GeoIP/GeoSite. | ||
# Currently updating: | ||
# - Geodat (GeoIP/Geosite) | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
# Update assets on every hour (xx:30) | ||
- cron: '30 * * * *' | ||
push: | ||
# Prevent triggering update request storm | ||
paths: | ||
- ".github/workflows/hourly-prepare.yml" | ||
pull_request: | ||
# Prevent triggering update request storm | ||
paths: | ||
- ".github/workflows/hourly-prepare.yml" | ||
|
||
jobs: | ||
geodat: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Restore Geodat Cache | ||
uses: actions/cache/restore@v4 | ||
with: | ||
path: resources | ||
key: xray-geodat- | ||
|
||
- name: Update Geodat | ||
id: update | ||
uses: nick-fields/retry@v3 | ||
with: | ||
timeout_minutes: 60 | ||
retry_wait_seconds: 60 | ||
max_attempts: 60 | ||
command: | | ||
[ -d 'resources' ] || mkdir resources | ||
LIST=('geoip geoip geoip' 'domain-list-community dlc geosite') | ||
for i in "${LIST[@]}" | ||
do | ||
INFO=($(echo $i | awk 'BEGIN{FS=" ";OFS=" "} {print $1,$2,$3}')) | ||
FILE_NAME="${INFO[2]}.dat" | ||
echo -e "Verifying HASH key..." | ||
HASH="$(curl -sL "https://raw.githubusercontent.com/v2fly/${INFO[0]}/release/${INFO[1]}.dat.sha256sum" | awk -F ' ' '{print $1}')" | ||
if [ -s "./resources/${FILE_NAME}" ] && [ "$(sha256sum "./resources/${FILE_NAME}" | awk -F ' ' '{print $1}')" == "${HASH}" ]; then | ||
continue | ||
else | ||
echo -e "Downloading https://raw.githubusercontent.com/v2fly/${INFO[0]}/release/${INFO[1]}.dat..." | ||
curl -L "https://raw.githubusercontent.com/v2fly/${INFO[0]}/release/${INFO[1]}.dat" -o ./resources/${FILE_NAME} | ||
echo -e "Verifying HASH key..." | ||
[ "$(sha256sum "./resources/${FILE_NAME}" | awk -F ' ' '{print $1}')" == "${HASH}" ] || { echo -e "The HASH key of ${FILE_NAME} does not match cloud one."; exit 1; } | ||
echo "unhit=true" >> $GITHUB_OUTPUT | ||
fi | ||
done | ||
- name: Save Geodat Cache | ||
uses: actions/cache/save@v4 | ||
if: ${{ steps.update.outputs.unhit }} | ||
with: | ||
path: resources | ||
key: xray-geodat-${{ github.sha }}-${{ github.run_number }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters