2023-09-07 03:29:42 +03:00

88 lines
2.4 KiB
YAML

name: "Update"
on:
workflow_dispatch:
schedule:
- cron: '8 3 * * *'
jobs:
updater:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install WHOIS client
run: sudo apt install -y whois
- name: Install JQ
run: sudo apt install -y jq
- name: Install ipcalc
run: sudo apt install -y ipcalc
- name: Install awk
run: sudo apt install -y awk
- name: Install GNU Parallel
run: sudo apt install -y parallel
- name: Set up Python 3.7
uses: actions/setup-python@v2
with:
python-version: '3.7'
- name: Cache pip
uses: actions/cache@v2
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 -x
find . -name downloader.sh| awk '{print "\nExecuting "$1"\n";system("bash "$1);exit}'
- name: Merge ipv4 Ranges
run: |
set -euo pipefail
set -x
find . -name ipv4.txt| 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| 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}