[TOOLS] Update filters action

This commit is contained in:
Carmelo Messina
2026-06-05 11:15:02 +02:00
parent 9c4e2ea0b5
commit 7cd61d4205
+22 -15
View File
@@ -16,37 +16,40 @@ jobs:
- name: Checkout main branch
uses: actions/checkout@v4
with:
repository: 'uazo/cromite'
ref: main
fetch-depth: 1
path: main
- name: Prepare output directory
run: mkdir -p out/filters
run: mkdir -p main/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)
url="${line%%=*}"
file="${line#*=}"
url=$(echo "$url" | xargs)
file=$(echo "$file" | 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
if ! curl -fL "$url" -o "main/out/filters/$file"; then
echo "FAILED: $url"
KO=1
fi
done < tools/images/update-cromite-org/filters-sources.txt
done < main/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
@@ -56,27 +59,31 @@ jobs:
if: success()
uses: actions/checkout@v4
with:
repository: 'uazo/cromite'
ref: pages
fetch-depth: 1
path: pages
- name: Deploy to gh-pages
if: success()
- name: Deploy to pages
run: |
# Replace old filters with new ones
cd pages
rm -rf filters
mkdir -p filters
cp -r out/filters/* filters/
cp -r ../main/out/filters/. filters/
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git add filters/*.txt
# add ONLY txt files
find filters -type f -name "*.txt" -exec git add {} +
# 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
git push https://x-access-token:${{ github.token }}@github.com/uazo/cromite.git HEAD:pages