You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.9 KiB
61 lines
1.9 KiB
name: "Update"
|
|
|
|
on:
|
|
schedule:
|
|
- cron: '8 */12 * * *' # At minute 8 past every 12th hour
|
|
|
|
jobs:
|
|
updater:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- name: Download IPs
|
|
run: |
|
|
bash google/downloader.sh
|
|
bash amazon/downloader.sh
|
|
|
|
- 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: Merge IPv4 ranges
|
|
run: |
|
|
set -euo pipefail
|
|
# ipv4
|
|
python utils/merge.py --source=google/ipv4.txt | sort -h > google/ipv4_merged.txt
|
|
python utils/merge.py --source=amazon/ipv4.txt | sort -h > amazon/ipv4_merged.txt
|
|
# ipv6
|
|
python utils/merge.py --source=google/ipv6.txt | sort -h > google/ipv6_merged.txt
|
|
python utils/merge.py --source=amazon/ipv6.txt | sort -h > amazon/ipv6_merged.txt
|
|
|
|
- name: Commit files
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
set -euo pipefail
|
|
git config --local user.email "$(git log --format='%ae' HEAD^!)"
|
|
git config --local user.name "$(git log --format='%an' HEAD^!)"
|
|
git remote add github "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
|
|
git pull github ${GITHUB_REF} --ff-only
|
|
git add .
|
|
if [ -z "$(git status --porcelain)" ]; then
|
|
echo 'No changes'
|
|
exit 0
|
|
fi
|
|
git commit -m "Update ip ranges"
|
|
git push github HEAD:${GITHUB_REF}
|
|
|