diff --git a/.github/workflows/geolite-update.yaml b/.github/workflows/geolite-update.yaml new file mode 100644 index 0000000000..dd5c70df71 --- /dev/null +++ b/.github/workflows/geolite-update.yaml @@ -0,0 +1,38 @@ +name: Update GeoLite2 Database +on: ['push'] +jobs: + update-geolite2-if-changed: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - shell: bash + env: + MAXMIND_LICENSE_KEY: ${{ secrets.MAXMIND_LICENSE_KEY }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + #!/bin/bash + set -eo pipefail + + DATE=$(date +%F_%H-%M-%S) + BRANCH_NAME=geolite2-update-$DATE + git checkout -b $BRANCH_NAME + + # Pull the new IP database + curl "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country&license_key=${MAXMIND_LICENSE_KEY}&suffix=tar.gz" \ + --output /tmp/geolite2-country.tar.gz + mkdir /tmp/dest + tar -xzf /tmp/geolite2-country.tar.gz -C /tmp/dest + mv /tmp/dest/*/GeoLite2-Country.mmdb util/ipresolver/GeoLite2-Country.mmdb + + # Commit and push the changes + git config user.email "runner@redhat.com" + git config user.name "runner" + git add util/ipresolver/GeoLite2-Country.mmdb + git commit -m "Update GeoLite2 database" + git push origin $BRANCH_NAME + + # Create the PR + gh pr create -B master -H $BRANCH_NAME \ + --title "Update GeoLite2 database $DATE" \ + --body 'Updating GeoLite2 database to latest version. PR created automatically by the Update GeoLite2 Database GitHub action.' + diff --git a/util/ipresolver/GeoLite2-Country.mmdb b/util/ipresolver/GeoLite2-Country.mmdb index bd98a33b10..7534d33093 100644 Binary files a/util/ipresolver/GeoLite2-Country.mmdb and b/util/ipresolver/GeoLite2-Country.mmdb differ