Skip to content

Update GeoIP2Fast dat files #40

Update GeoIP2Fast dat files

Update GeoIP2Fast dat files #40

Workflow file for this run

name: Update GeoIP2Fast dat files
on:
repository_dispatch:
workflow_dispatch:
schedule:
- cron: 0 21 * * 2,5
jobs:
run:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/[email protected]
- 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/[email protected]
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 + 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
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: Check coverage percentage
run: |
PERCENTAGE=$(python3 geoip2fast/geoip2fast.py --coverage | grep IPv4 | awk '{print $4}' | sed 's/%//g')
python3 geoip2fast/geoip2fast.py --coverage > "IPv4_Coverage_${PERCENTAGE}_percent.txt"
- name: Upload to Releases
uses: softprops/[email protected]
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/[email protected]
with:
keep_latest: 5
delete_tags: true
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
permissions:
contents: write
discussions: write