From 7cd61d4205b459b8b3162688bd489ce39cb423c2 Mon Sep 17 00:00:00 2001 From: Carmelo Messina Date: Fri, 5 Jun 2026 11:15:02 +0200 Subject: [PATCH] [TOOLS] Update filters action --- .github/workflows/update-filters.yml | 37 +++++++++++++++++----------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/.github/workflows/update-filters.yml b/.github/workflows/update-filters.yml index d4ff65f6..e53d40d7 100644 --- a/.github/workflows/update-filters.yml +++ b/.github/workflows/update-filters.yml @@ -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 \ No newline at end of file + + git push https://x-access-token:${{ github.token }}@github.com/uazo/cromite.git HEAD:pages \ No newline at end of file