11name : Publish GeoLite2 Mirror
2+
23on :
34 repository_dispatch :
45 workflow_dispatch :
56 schedule :
67 - cron : 0 22 * * 2,5
8+
79jobs :
810 run :
911 runs-on : ubuntu-latest
1012 timeout-minutes : 5
13+
1114 steps :
1215 - name : Download GeoLite.mmdb
1316 run : |
@@ -16,24 +19,29 @@ jobs:
1619 wget -nv -O- "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country&license_key=${{ secrets.MAXMIND_KEY }}&suffix=tar.gz" | tar zxv
1720 mkdir -p upload
1821 cp -v GeoLite*/*.mmdb upload
22+
1923 - name : Download GeoLite.csv
2024 run : |
2125 wget -nv -O GeoLite2-ASN-CSV.zip "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-ASN-CSV&license_key=${{ secrets.MAXMIND_KEY }}&suffix=zip"
2226 wget -nv -O GeoLite2-Country-CSV.zip "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country-CSV&license_key=${{ secrets.MAXMIND_KEY }}&suffix=zip"
2327 wget -nv -O GeoLite2-City-CSV.zip "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City-CSV&license_key=${{ secrets.MAXMIND_KEY }}&suffix=zip"
28+
2429 - name : Decompress Zips
2530 uses : TonyBogdanov/zip@1.0
2631 with :
27- args : unzip -qq GeoLite2-*-CSV.zip
32+ args : unzip -qq GeoLite2-*-CSV.zip
33+
2834 - name : Prepare ENV variables
2935 run : |
3036 TAG_DATE=$(ls -d GeoLite2-Country-CSV_* | awk -F '_' '{print $2}')
3137 echo "TAG_DATE=$TAG_DATE" >> $GITHUB_ENV
3238 cat $GITHUB_ENV > "Geolite2-${TAG_DATE}"
39+
3340 - name : Copy GeoLite2.csv
3441 run : |
3542 cp -v GeoLite*/*.csv upload
3643 mv -v *.zip upload
44+
3745 - name : Upload to Releases
3846 uses : softprops/action-gh-release@v0.1.15
3947 env :
5058 upload/GeoLite2-ASN*.csv
5159 upload/GeoLite2-Country*.csv
5260 upload/GeoLite2-City*.csv
61+
62+ - name : Notify via Discord (Success)
63+ if : success()
64+ run : |
65+ TIME=$(date +"%Y-%m-%d %H:%M:%S")
66+ curl -H "Content-Type: application/json" \
67+ -X POST -d "$(jq -n --arg repo "${{ github.repository }}" \
68+ --arg workflow "${{ github.workflow }}" \
69+ --arg time "$TIME" \
70+ --arg tag "${{ env.TAG_DATE }}" \
71+ '{
72+ "embeds": [{
73+ "title": "✅ GeoLite2 Mirror Published",
74+ "description": "GeoLite2 files have been downloaded and published successfully.",
75+ "color": 3066993,
76+ "fields": [
77+ {"name": "Repository", "value": $repo, "inline": true},
78+ {"name": "Workflow", "value": $workflow, "inline": true},
79+ {"name": "Release Tag", "value": $tag, "inline": true},
80+ {"name": "Time", "value": $time, "inline": false}
81+ ],
82+ "footer": {"text": "Skiddle Bot | GitHub Actions"}
83+ }]
84+ }')" ${{ secrets.DISCORD_WEBHOOK }}
85+ shell : bash
86+
87+ - name : Notify via Discord (Failure)
88+ if : failure()
89+ run : |
90+ TIME=$(date +"%Y-%m-%d %H:%M:%S")
91+ curl -H "Content-Type: application/json" \
92+ -X POST -d "$(jq -n --arg repo "${{ github.repository }}" \
93+ --arg workflow "${{ github.workflow }}" \
94+ --arg time "$TIME" \
95+ '{
96+ "embeds": [{
97+ "title": "❌ GeoLite2 Mirror Failed",
98+ "description": "An error occurred during the GeoLite2 mirror process.",
99+ "color": 15158332,
100+ "fields": [
101+ {"name": "Repository", "value": $repo, "inline": true},
102+ {"name": "Workflow", "value": $workflow, "inline": true},
103+ {"name": "Time", "value": $time, "inline": false}
104+ ],
105+ "footer": {"text": "Skiddle Bot | GitHub Actions"}
106+ }]
107+ }')" ${{ secrets.DISCORD_WEBHOOK }}
108+ shell : bash
0 commit comments