.github/workflows/get-geolite2.yml #78
Workflow file for this run
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: Get GeoLite2 database | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "20 4 * * tue,fri" | |
env: | |
RELEASE_NAME: $(date +%Y%m%d%H%M) | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get GeoLite2 | |
env: | |
LICENSE_KEY: ${{ secrets.MAXMIND_GEOLITE2_LICENSE }} | |
run: | | |
mkdir -p geolite2 && cd geolite2 | |
curl --connect-timeout 15 -sSL "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country-CSV&license_key=${LICENSE_KEY}&suffix=zip" -o GeoLite2-Country-CSV.zip | |
curl --connect-timeout 15 -sSL "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-ASN&license_key=${LICENSE_KEY}&suffix=tar.gz" -o GeoLite2-ASN.tar.gz | |
unzip GeoLite2-Country-CSV.zip && tar -xvzf GeoLite2-ASN.tar.gz | |
mv GeoLite2-Country-CSV* . && mv GeoLite2-ASN*/GeoLite2-ASN.mmdb . | |
rm -f GeoLite2-Country-CSV.zip GeoLite2-ASN.tar.gz GeoLite2-ASN/* | |
- name: Check if files were downloaded | |
run: | | |
cd geolite2 || exit 1 | |
if [ "$(ls -A .)" ]; then | |
echo "Files exist, proceeding to commit." | |
else | |
echo "No files to commit, exiting." | |
exit 1 | |
fi | |
- name: Push assets to geolite2 branch | |
run: | | |
cd geolite2 || exit 1 | |
git init | |
git config --local user.name "github-actions[bot]" | |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git checkout -b geolite2 | |
git add . | |
git commit -m "${{ env.RELEASE_NAME }}" | |
git remote add origin "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}" | |
git push -f origin geolite2 | |
# Enable debug logging for troubleshooting (optional) | |
- name: Enable Debug Logging | |
env: | |
ACTIONS_RUNNER_DEBUG: true | |
ACTIONS_STEP_DEBUG: true |