Process GeoIP Datasets (IPv4 Only) #18
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: Process GeoIP Datasets (IPv4 Only) | |
on: | |
schedule: | |
- cron: "0 0 * * *" # Runs daily at midnight | |
workflow_dispatch: # Allows manual triggering from GitHub UI | |
jobs: | |
process-datasets: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Checkout Repository | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
# Step 2: Download GeoIP Data (only) | |
- name: Download GeoIP Data | |
run: | | |
mkdir -p datasets | |
curl -L -o datasets/geoip.txt \ | |
https://raw.githubusercontent.com/Chocolate4U/Iran-clash-rules/release/ircidr.txt | |
echo "Downloaded GeoIP data." | |
# Step 3: Process GeoIP Data (IPv4 only) | |
- name: Format GeoIP Data (IPv4 only) | |
run: | | |
mkdir -p output | |
# Extract only IPv4 lines (CIDRs) from geoip.txt | |
grep -E '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/' datasets/geoip.txt \ | |
> output/iran-ipv4.txt | |
echo "Formatted GeoIP data (IPv4 only) to output/iran-ipv4.txt" | |
# Step 4: Commit and Push Processed Files | |
- name: Commit and Push Processed Files | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
# Configure Git | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
# Create/update the "processed-data" branch | |
git checkout -B processed-data | |
# Move generated file from output/ into the repo root | |
mv output/iran-ipv4.txt iran-ipv4.txt | |
# Stage changes | |
git add iran-ipv4.txt | |
# Commit only if there's a diff | |
git diff --cached --quiet || git commit -m "Update processed IPv4 CIDRs" | |
# Push (force in case the branch doesn’t exist yet) | |
git push -f origin processed-data |