Skip to content

Fetch IPs

Fetch IPs #8

Workflow file for this run

name: Fetch IPs
on:
schedule:
- cron: '0 */2 * * *' # Co 2 godziny
workflow_dispatch:
jobs:
fetch-data:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
ref: main
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'npm'
- name: Install dependencies
run: npm install
- name: Fetch IPs from API and update files
run: node worker.js
env:
SEFIN_API_KEY: ${{ secrets.SEFIN_API_KEY }}
- name: Run git pull
run: git pull origin main
- name: Add files to staging
run: git add .
- name: Commit and push changes
run: |
git config user.name "Sefinek Actions"
git config user.email "[email protected]"
if [ -n "$(git status -s)" ]; then
MODIFIED_FILES=$(git diff --name-only HEAD | grep -v '^cache/')
FILE_COUNT=$(echo "$MODIFIED_FILES" | wc -l)
if [ "$FILE_COUNT" -gt 0 ]; then
git commit -am "Bi-hourly update of blocklists [$FILE_COUNT files] - $(date -u '+%Y-%m-%d %H:%M:%S UTC')" -m "$MODIFIED_FILES"
git push origin main
else
echo "Canceled. No files to commit after excluding cache/ files."
fi
else
echo "Canceled. No changes to commit."
fi
env:
GITHUB_TOKEN: ${{ secrets.SEFINEK_ACTIONS_PAT }}