TOOLS: publish filters on git pages

This commit is contained in:
Carmelo Messina
2026-06-05 10:55:06 +02:00
parent c266f670b3
commit 9c4e2ea0b5
2 changed files with 138 additions and 0 deletions
+82
View File
@@ -0,0 +1,82 @@
name: Update Filters
on:
schedule:
- cron: "0 3 */2 * *" # every 2 days at 03:00 UTC
workflow_dispatch:
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout main branch
uses: actions/checkout@v4
with:
ref: main
- name: Prepare output directory
run: mkdir -p out/filters
- name: Download filter lists (fail-safe)
run: |
set -e
KO=0
# Read each URL from the sources file
while IFS= read -r line; do
[ -z "$line" ] && continue
url=$(echo "$line" | cut -d '=' -f1 | xargs)
file=$(echo "$line" | cut -d '=' -f2 | xargs)
# fallback: if no filename provided, use basename
if [ -z "$file" ]; then
file=$(basename "$url")
fi
echo "Downloading $url -> $file"
if ! curl -fL "$url" -o "out/filters/$file"; then
echo "FAILED: $url"
KO=1
fi
done < tools/images/update-cromite-org/filters-sources.txt
# Abort deployment if any download failed
if [ "$KO" -ne 0 ]; then
echo "One or more downloads failed. Aborting deploy."
exit 1
fi
- name: Checkout gh-pages branch
if: success()
uses: actions/checkout@v4
with:
ref: pages
fetch-depth: 1
- name: Deploy to gh-pages
if: success()
run: |
# Replace old filters with new ones
rm -rf filters
mkdir -p filters
cp -r out/filters/* filters/
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git add filters/*.txt
# Skip commit if nothing changed
if git diff --cached --quiet; then
echo "No changes detected"
exit 0
fi
git commit -m "Update filters ($(date -u))"
git push origin gh-pages