Skip to content

Update

Update #986

Workflow file for this run

name: "Update"
on:
workflow_dispatch:
schedule:
- cron: '8 3 * * *'
jobs:
updater:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Prepare packages
run: sudo apt-get install -y whois jq ipcalc ripgrep gawk parallel
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Cache pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('utils/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Install dependencies
run: |
pip install -r utils/requirements.txt
- name: Download IPs
run: |
set -euo pipefail
set -x
find . -name downloader.sh| sort -h | awk '{print "Executing "$1"...";system("bash "$1)}'
- name: Merge ipv4 Ranges
run: |
set -euo pipefail
set -x
find . -name ipv4.txt| sort -h | parallel --will-cite -j 1 echo "Merging '{}'"';'python utils/merge.py --source={} '|' sort -h '>' {.}_merged.txt
- name: Merge ipv6 Ranges
run: |
set -euo pipefail
set -x
find . -name ipv6.txt| sort -h | parallel --will-cite -j 1 echo "Merging '{}'"';'python utils/merge.py --source={} '|' sort -h '>' {.}_merged.txt
- name: Commit files
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
git remote add github "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git pull github ${GITHUB_REF} --ff-only
# Get name & email from 1st commit
git config --local user.email "$(git log --format='%ae' --reverse | head -1)"
git config --local user.name "$(git log --format='%an' --reverse | head -1)"
# try commit
git add .
if [ -z "$(git status --porcelain)" ]; then
echo 'No changes'
exit 0
fi
git commit -m "Auto-update ip ranges"
# push changes
git push github HEAD:${GITHUB_REF}