mirror of
https://github.com/MrUnknownDE/utools.git
synced 2026-04-06 00:32:04 +02:00
add weekly maxmind update for repo
This commit is contained in:
93
.github/workflows/maxmind-update.yml
vendored
Normal file
93
.github/workflows/maxmind-update.yml
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
name: Update MaxMind GeoLite2 DBs
|
||||
|
||||
on:
|
||||
workflow_dispatch: # Ermöglicht manuelles Starten
|
||||
schedule:
|
||||
# Läuft jeden Dienstag um 05:00 UTC (anpassbar)
|
||||
- cron: '0 5 * * 2'
|
||||
|
||||
jobs:
|
||||
update-db:
|
||||
runs-on: ubuntu-latest
|
||||
# Berechtigung, um Änderungen zurück ins Repo zu pushen
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Download geoipupdate tool
|
||||
run: |
|
||||
# Lade eine spezifische Version oder die neueste herunter
|
||||
GEOIPUPDATE_VERSION="4.11.1" # Beispielversion, prüfe auf neuere Releases
|
||||
wget "https://github.com/maxmind/geoipupdate/releases/download/v${GEOIPUPDATE_VERSION}/geoipupdate_${GEOIPUPDATE_VERSION}_linux_amd64.tar.gz"
|
||||
tar -zxvf "geoipupdate_${GEOIPUPDATE_VERSION}_linux_amd64.tar.gz"
|
||||
# Verschiebe das Binary in einen bekannten Pfad und mache es ausführbar
|
||||
sudo mv "geoipupdate_${GEOIPUPDATE_VERSION}_linux_amd64/geoipupdate" /usr/local/bin/
|
||||
sudo chmod +x /usr/local/bin/geoipupdate
|
||||
# Überprüfe die Version
|
||||
geoipupdate -V
|
||||
|
||||
- name: Create GeoIP.conf
|
||||
# Erstellt die Konfigurationsdatei für geoipupdate mit den Secrets
|
||||
# Wichtig: Secrets nicht direkt im Log ausgeben!
|
||||
run: |
|
||||
echo "Creating GeoIP.conf..."
|
||||
cat << EOF > GeoIP.conf
|
||||
# GeoIP.conf file for geoipupdate
|
||||
# Replace with your actual AccountID and LicenseKey from GitHub Secrets
|
||||
AccountID ${{ secrets.MAXMIND_ACCOUNT_ID }}
|
||||
LicenseKey ${{ secrets.MAXMIND_LICENSE_KEY }}
|
||||
|
||||
# Specify the editions to download
|
||||
EditionIDs GeoLite2-ASN GeoLite2-City
|
||||
EOF
|
||||
echo "GeoIP.conf created."
|
||||
# Umgebungsvariablen für Sicherheit (werden nicht geloggt)
|
||||
env:
|
||||
MAXMIND_ACCOUNT_ID: ${{ secrets.MAXMIND_ACCOUNT_ID }}
|
||||
MAXMIND_LICENSE_KEY: ${{ secrets.MAXMIND_LICENSE_KEY }}
|
||||
|
||||
- name: Run geoipupdate
|
||||
run: |
|
||||
echo "Running geoipupdate..."
|
||||
# -f gibt die Konfigurationsdatei an
|
||||
# -d gibt das Zielverzeichnis an (relativ zum Repo-Root)
|
||||
# -v für ausführliche Ausgabe (hilft beim Debuggen)
|
||||
geoipupdate -f GeoIP.conf -d ./backend/data -v
|
||||
echo "geoipupdate finished."
|
||||
|
||||
- name: Check for changes
|
||||
id: check_changes
|
||||
run: |
|
||||
# Prüfe, ob sich die .mmdb Dateien geändert haben
|
||||
if git status --porcelain | grep -q 'backend/data/.*\.mmdb'; then
|
||||
echo "Changes detected in MaxMind databases."
|
||||
echo "changed=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "No changes detected in MaxMind databases."
|
||||
echo "changed=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Commit and push changes
|
||||
# Nur ausführen, wenn Schritt 'check_changes' Änderungen gemeldet hat
|
||||
if: steps.check_changes.outputs.changed == 'true'
|
||||
run: |
|
||||
echo "Committing and pushing changes..."
|
||||
git config --global user.name 'github-actions[bot]'
|
||||
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
|
||||
git add ./backend/data/*.mmdb
|
||||
# Erstelle Commit-Nachricht mit Datum
|
||||
COMMIT_DATE=$(date -u +"%Y-%m-%d")
|
||||
git commit -m "Update MaxMind GeoLite2 databases (${COMMIT_DATE})"
|
||||
# Pushe zum aktuellen Branch (z.B. main)
|
||||
git push
|
||||
echo "Changes pushed."
|
||||
# Umgebungsvariable für den Token (wird automatisch von GitHub bereitgestellt)
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: No changes to commit
|
||||
if: steps.check_changes.outputs.changed == 'false'
|
||||
run: echo "Skipping commit as no database files were updated."
|
||||
@@ -68,7 +68,6 @@ This method uses the Docker images automatically built and pushed to GitHub Cont
|
||||
PORT: 3000
|
||||
LOG_LEVEL: info # Adjust log level if needed (e.g., 'debug', 'warn')
|
||||
PING_COUNT: 4
|
||||
# MaxMind DB paths are set within the image, no need to override usually
|
||||
dns:
|
||||
# Explicitly set reliable public DNS servers for rDNS lookups inside the container
|
||||
- 1.1.1.1 # Cloudflare DNS
|
||||
|
||||
Reference in New Issue
Block a user