Blocklists Update #1302
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: Blocklists Update | |
on: | |
schedule: | |
- cron: '0 */2 * * *' | |
workflow_dispatch: | |
permissions: | |
contents: write | |
jobs: | |
blocklists_update: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
id: setup_python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.13' | |
- name: Restore cached virtualenv | |
uses: actions/cache/restore@v4 | |
with: | |
key: venv-${{ runner.os }}-python-${{ steps.setup_python.outputs.python-version }} | |
path: .venv_blocklist | |
- name: Install necessary packages | |
run: | | |
packages="requests ipaddress geoip2 path" | |
if [ ! -d ".venv_blocklist" ]; then | |
python -m venv .venv_blocklist | |
source .venv_blocklist/bin/activate | |
pip install $packages | |
else | |
source .venv_blocklist/bin/activate | |
installed_packages=$(pip freeze) | |
required_packages=($packages) | |
packages_installed=false | |
for package in "${required_packages[@]}"; do | |
if ! echo "$installed_packages" | grep -q "^${package}"; then | |
echo "Missing or incorrect $package. Installing the required packages." | |
pip install $packages | |
packages_installed=true | |
fi | |
done | |
if [ "$packages_installed" = false ]; then | |
echo "Using cached virtualenv" | |
fi | |
fi | |
echo "$PWD/.venv_blocklist/bin" >> $GITHUB_PATH | |
echo "VIRTUAL_ENV=$PWD/.venv_blocklist" >> $GITHUB_ENV | |
- name: Save cached virtualenv | |
uses: actions/cache@v4 | |
with: | |
key: venv-${{ runner.os }}-python-${{ steps.setup_python.outputs.python-version }} | |
path: .venv_blocklist | |
- name: Remove previous blocklists | |
run: | | |
rm -Rf ./blocklists | |
rm -Rf ./blocklists_split | |
- name: Run blocklists update scripts | |
run: | | |
python blocklists_update.py | |
python blocklists_statistics.py | |
python blocklists_update_urls_readme.py | |
- name: Execute Git push script | |
shell: bash | |
run: | | |
chmod +x blocklists_git_push.sh | |
./blocklists_git_push.sh ${{ secrets.GITHUB_TOKEN }} |