GeoLite.mmdb/.github/workflows/GeoLite.yml
2023-04-12 06:25:34 -07:00

84 lines
3.1 KiB
YAML

#
# Copyright (c) 2020-2021 P3TERX <https://p3terx.com>
#
# This is free software, licensed under the MIT License.
# See /LICENSE for more information.
#
# https://github.com/P3TERX/GeoLite.mmdb
# Description: Publish GeoLite.mmdb
#
name: Publish GeoLite.mmdb
on:
repository_dispatch:
workflow_dispatch:
schedule:
- cron: 0 1 */3 * *
jobs:
run:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Download GeoLite.mmdb
run: |
wget -nv -O- "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-ASN&license_key=${{ secrets.LICENSE_KEY }}&suffix=tar.gz" | tar zxv
wget -nv -O- "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=${{ secrets.LICENSE_KEY }}&suffix=tar.gz" | tar zxv
wget -nv -O- "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country&license_key=${{ secrets.LICENSE_KEY }}&suffix=tar.gz" | tar zxv
mkdir -p upload
cp -v GeoLite*/*.mmdb upload
echo "TAG_NAME=$(date +"%Y.%m.%d")" >> $GITHUB_ENV
- name: Download GeoLite.csv
run: |
wget -nv -O GeoLite2-ASN-CSV.zip "https://download.maxmind.com/app/geoip_download_by_token?edition_id=GeoLite2-ASN-CSV&license_key=${{ secrets.LICENSE_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.LICENSE_KEY }}&suffix=zip"
wget -nv -O GeoLite2-City-CSV.zip "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City-CSV&license_key=${{ secrets.LICENSE_KEY }}&suffix=zip"
- name: Decompress Zips
uses: TonyBogdanov/zip@1.0
with:
args: unzip -qq GeoLite2-*-CSV.zip
- name: Copy GeoLite2.csv
run: |
cp -v GeoLite*/*.csv upload
split -l 650000 -d --additional-suffix .csv upload/GeoLite2-City-Blocks-IPv4.csv upload/GeoLite2-City-Blocks-IPv4.csv.
rm upload/GeoLite2-City-Blocks-IPv4.csv
split -l 650000 -d --additional-suffix .csv upload/GeoLite2-City-Blocks-IPv6.csv upload/GeoLite2-City-Blocks-IPv6.csv.
rm upload/GeoLite2-City-Blocks-IPv6.csv
echo "TAG_NAME=$(date +"%Y.%m.%d")" >> $GITHUB_ENV
- name: Push to "download" branch
run: |
cd upload
git init
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
git checkout -b download
git add .
git commit -m "${{ env.TAG_NAME }}"
git remote add origin "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}"
git push -f origin download
- name: Upload to Releases
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.TAG_NAME }}
body: ${{ env.TAG_NAME }}
files: |
upload/*.mmdb
upload/*.csv
- name: Remove old Releases
uses: dev-drprasad/delete-older-releases@v0.2.0
with:
keep_latest: 2
delete_tags: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}