Update GeoIP2Fast dat files #44
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
name: Update GeoIP2Fast dat files | |
on: | |
repository_dispatch: | |
workflow_dispatch: | |
schedule: | |
- cron: 0 22 * * 2,5 | |
jobs: | |
run: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4.1.1 | |
- name: Download Geolite2 CSV files from Maxmind | |
run: | | |
mkdir -p geolite2 | |
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" | |
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" | |
- name: Decompress Geolite2 zip files | |
uses: TonyBogdanov/zip@1.0 | |
with: | |
args: unzip -qq GeoLite2-*-CSV.zip | |
- name: Prepare ENV variables | |
run: | | |
TAG_DATE=$(ls -d GeoLite2-Country-CSV_* | awk -F '_' '{print $2}') | |
echo "TAG_DATE=$TAG_DATE" >> $GITHUB_ENV | |
cat $GITHUB_ENV > Maxmind-Geolite2-CSV_$TAG_DATE | |
- name: Copy GeoLite2 CSV files | |
run: | | |
cp -v GeoLite*/*.csv geolite2 | |
- name: Create geoip2fast.dat.gz with Country + IPv4 | |
run: | | |
python3 geoip2fast/geoip2dat.py --country-dir ./geolite2/ --output-dir ./ | |
mv -vf geoip2fast.dat.gz geoip2fast/geoip2fast.dat.gz | |
- name: Create geoip2fast.dat.gz with Country + IPv4 + IPv6 | |
run: | | |
python3 geoip2fast/geoip2dat.py --country-dir ./geolite2/ --output-dir ./ --with-ipv6 | |
mv -vf geoip2fast.dat.gz geoip2fast/geoip2fast-ipv6.dat.gz | |
- name: Create geoip2fast.dat.gz with Country + ASN + IPv4 | |
run: | | |
python3 geoip2fast/geoip2dat.py --country-dir ./geolite2/ --asn-dir ./geolite2/ --output-dir ./ | |
mv -vf geoip2fast.dat.gz geoip2fast/geoip2fast-asn.dat.gz | |
- name: Create geoip2fast.dat.gz with Country + ASN + IPv4 + IPv6 | |
run: | | |
python3 geoip2fast/geoip2dat.py --country-dir ./geolite2/ --asn-dir ./geolite2/ --output-dir ./ --with-ipv6 | |
PERCENTAGE=$(python3 geoip2fast/geoip2fast.py --coverage | grep IPv4 | awk '{print $4}' | sed 's/%//g') | |
python3 geoip2fast/geoip2fast.py --coverage > "IPv4_Coverage_${PERCENTAGE}_percent.txt" | |
mv -vf geoip2fast.dat.gz geoip2fast/geoip2fast-asn-ipv6.dat.gz | |
- name: Push to "main" branch | |
run: | | |
cd geoip2fast | |
git config user.name "${{ github.actor }}" | |
git config user.email "${{ github.actor }}@users.noreply.github.com" | |
git add geoip2fast*.gz | |
git commit -m "Updated dat.gz from Maxmind-CSV_${{ env.TAG_DATE }}" | |
git remote set-url origin "https://${{ secrets.TOKEN }}@github.com/${{ github.repository }}" | |
git push -f origin main | |
- name: Upload to Releases | |
uses: softprops/action-gh-release@v0.1.15 | |
env: | |
GITHUB_TOKEN: ${{ secrets.TOKEN }} | |
with: | |
name: Latest DAT files ${{ env.TAG_DATE }} | |
tag_name: ${{ env.TAG_DATE }} | |
body: GeoIP2Fast latest dat.gz files with Maxmind Geolite2 database from ${{ env.TAG_DATE }} | |
token: ${{ secrets.TOKEN }} | |
files: | | |
Maxmind-Geolite2-CSV_* | |
IPv4_Coverage_* | |
geoip2fast/*.gz | |
- name: Remove old Releases | |
uses: dev-drprasad/delete-older-releases@v0.3.2 | |
with: | |
keep_latest: 5 | |
delete_tags: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.TOKEN }} | |
permissions: | |
contents: write | |
discussions: write |