Update Malicious IPs #572
This file contains hidden or 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: Update Malicious IPs | |
on: | |
schedule: | |
- cron: '0 */5 * * *' | |
workflow_dispatch: | |
permissions: | |
contents: write | |
concurrency: | |
group: update-malicious-ips | |
cancel-in-progress: false | |
jobs: | |
update-malicious-ips: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
ref: main | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 22.x | |
cache: npm | |
- name: Install dependencies | |
run: npm ci --omit=dev | |
- name: Fetch malicious IPs from api.sefinek.net | |
run: node . --secret=${{ secrets.API_SECRET_TOKEN }} | |
- name: Cleanup | |
run: node scripts/cleanup.js | |
- name: Commit and push changes | |
env: | |
COMMIT_NAME: Sefinek Actions | |
COMMIT_EMAIL: ${{ secrets.GH_EMAIL_ADDRESS }} | |
run: | | |
set -euo pipefail | |
git config user.name "$COMMIT_NAME" | |
git config user.email "$COMMIT_EMAIL" | |
git add -A | |
if git diff --cached --quiet; then | |
echo "Canceled: Nothing to commit." | |
exit 0 | |
fi | |
MODIFIED_FILES=$(git diff --cached --name-only) | |
FILE_COUNT=$(printf '%s\n' "$MODIFIED_FILES" | grep -c . || true) | |
git commit -m "Updated list of malicious IP addresses [$FILE_COUNT file(s)]" \ | |
-m "$MODIFIED_FILES" | |
git fetch origin main | |
git rebase origin/main || { | |
echo "Rebase failed. Aborting." | |
git rebase --abort || true | |
exit 1 | |
} | |
git push origin HEAD:main |