mirror of
https://github.com/Prowlarr/Indexers.git
synced 2026-04-25 02:48:27 +01:00
- Add external blocklist configuration (scripts/blocklist.txt) - Fix conflict detection using proper git commands (diff --filter=U) - Expand list of unwanted file types (images, code files, etc) - Remove Jackett src/ files and unwanted assets automatically - Better handling of both-added (AA) conflicts - Simplify commit logic (remove retry mechanism) - Better error handling for empty commits - Enhanced GitHub Actions workflow with exit code handling - Auto force-push for automated-indexer-sync branch only - Manual force-push with -f flag for other branches Co-authored-by: ServarrAdmin <development@lidarr.audio>
196 lines
6.0 KiB
YAML
196 lines
6.0 KiB
YAML
---
|
||
name: Indexer Sync Automation
|
||
|
||
on:
|
||
schedule:
|
||
# Run 3 times daily every 8 hours
|
||
- cron: '0 */8 * * *'
|
||
workflow_dispatch:
|
||
inputs:
|
||
force_sync:
|
||
description: 'Force sync even if up to date'
|
||
required: false
|
||
default: false
|
||
type: boolean
|
||
mode:
|
||
description: 'Execution mode'
|
||
required: false
|
||
default: 'normal'
|
||
type: choice
|
||
options:
|
||
- normal
|
||
- development
|
||
debug_mode:
|
||
description: 'Enable debug logging (DEBUG=true)'
|
||
required: false
|
||
default: false
|
||
type: boolean
|
||
verbose_mode:
|
||
description: 'Enable verbose logging (VERBOSE=true)'
|
||
required: false
|
||
default: false
|
||
type: boolean
|
||
target_branch:
|
||
description: 'Target branch for sync (automated-indexer-sync/master)'
|
||
required: false
|
||
default: 'automated-indexer-sync'
|
||
type: choice
|
||
options:
|
||
- automated-indexer-sync
|
||
- master
|
||
|
||
concurrency:
|
||
group: ${{ github.workflow }}-${{ github.ref }}
|
||
cancel-in-progress: true
|
||
|
||
jobs:
|
||
sync-indexers:
|
||
name: Sync Indexers from Jackett
|
||
runs-on: ubuntu-latest
|
||
if: github.repository == 'Prowlarr/Indexers'
|
||
permissions:
|
||
contents: write
|
||
|
||
steps:
|
||
- name: Checkout repository
|
||
uses: actions/checkout@v5
|
||
with:
|
||
token: ${{ secrets.GITHUB_TOKEN }}
|
||
fetch-depth: 50
|
||
fetch-tags: false
|
||
|
||
- name: Cache Python dependencies
|
||
uses: actions/cache@v4
|
||
with:
|
||
path: |
|
||
~/.cache/pip
|
||
.venv
|
||
key: python-deps-${{ runner.os }}-${{ hashFiles('requirements.txt') }}
|
||
restore-keys: |
|
||
python-deps-${{ runner.os }}-
|
||
|
||
- name: Setup Python
|
||
uses: actions/setup-python@v5
|
||
with:
|
||
python-version: '3.11'
|
||
|
||
- name: Create virtual environment and install dependencies
|
||
run: |
|
||
if [ ! -d ".venv" ]; then
|
||
python3 -m venv .venv
|
||
fi
|
||
# shellcheck disable=SC1091
|
||
source .venv/bin/activate
|
||
# Ensure pip is installed and upgraded
|
||
python -m ensurepip --upgrade || true
|
||
python -m pip install --upgrade pip
|
||
python -m pip install -r requirements.txt
|
||
|
||
- name: Configure git
|
||
run: |
|
||
git config --global user.name "github-actions[bot]"
|
||
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
||
git config --global fetch.prune true
|
||
git config advice.mergeConflict false
|
||
# Add Jackett remote if it doesn't exist
|
||
if ! git remote get-url z_Jackett >/dev/null 2>&1; then
|
||
git remote add z_Jackett https://github.com/Jackett/Jackett.git
|
||
fi
|
||
git config --global remote.z_Jackett.tagOpt --no-tags
|
||
|
||
- name: Fetch repositories
|
||
run: |
|
||
echo "🔄 Fetching Jackett repository..."
|
||
git fetch z_Jackett master --depth=50
|
||
echo "✅ Jackett repository fetched successfully"
|
||
|
||
echo "🔄 Fetching prowlarr/indexers repository..."
|
||
git fetch origin master --depth=50
|
||
echo "✅ prowlarr/indexers repository fetched successfully"
|
||
|
||
- name: Run indexer sync
|
||
id: sync_attempt
|
||
run: |
|
||
# Activate virtual environment if it exists
|
||
if [ -d ".venv" ]; then
|
||
# shellcheck disable=SC1091
|
||
source .venv/bin/activate
|
||
fi
|
||
|
||
# Run the sync script with -z mode, automation mode, and push enabled
|
||
TARGET_BRANCH="${{ github.event.inputs.target_branch || 'automated-indexer-sync' }}"
|
||
MODE="${{ github.event.inputs.mode || 'normal' }}"
|
||
|
||
# Build flags based on inputs
|
||
FLAGS="-z -a -p -b $TARGET_BRANCH -o origin -m $MODE"
|
||
|
||
if [ "${{ github.event.inputs.debug_mode }}" = "true" ]; then
|
||
FLAGS="$FLAGS -d"
|
||
fi
|
||
|
||
if [ "${{ github.event.inputs.verbose_mode }}" = "true" ]; then
|
||
FLAGS="$FLAGS -v"
|
||
fi
|
||
|
||
if [ "${{ github.event.inputs.force_sync }}" = "true" ]; then
|
||
FLAGS="$FLAGS -f"
|
||
fi
|
||
|
||
echo "🔄 Running: ./scripts/indexer-sync-v2.sh $FLAGS"
|
||
echo "📝 Target branch: $TARGET_BRANCH"
|
||
echo "⚙️ Mode: $MODE"
|
||
|
||
# Run with error handling
|
||
set +e
|
||
./scripts/indexer-sync-v2.sh $FLAGS
|
||
EXIT_CODE=$?
|
||
set -e
|
||
|
||
# Handle specific exit codes
|
||
case $EXIT_CODE in
|
||
0)
|
||
echo "✅ Sync completed successfully"
|
||
exit 0
|
||
;;
|
||
3)
|
||
echo "⚠️ Failed to parse Prowlarr commits - may need manual investigation"
|
||
exit $EXIT_CODE
|
||
;;
|
||
4)
|
||
echo "⚠️ Too many commits to cherry-pick - exceeds safety limit"
|
||
exit $EXIT_CODE
|
||
;;
|
||
5)
|
||
echo "⚠️ Unresolved conflicts in automation mode"
|
||
exit $EXIT_CODE
|
||
;;
|
||
6)
|
||
echo "⚠️ Unresolved conflicts before commit"
|
||
exit $EXIT_CODE
|
||
;;
|
||
7)
|
||
echo "⚠️ Failed to create commit - possibly no changes or git error"
|
||
# This could be a transient failure or mean we're already up to date
|
||
# Check if there are actually any differences
|
||
if git diff --quiet origin/master...HEAD; then
|
||
echo "ℹ️ No actual changes detected - already up to date"
|
||
exit 0
|
||
else
|
||
exit $EXIT_CODE
|
||
fi
|
||
;;
|
||
8)
|
||
echo "⚠️ Failed to push changes"
|
||
exit $EXIT_CODE
|
||
;;
|
||
*)
|
||
echo "⚠️ Unknown error occurred (exit code: $EXIT_CODE)"
|
||
exit $EXIT_CODE
|
||
;;
|
||
esac
|
||
|
||
- name: Summary
|
||
run: |
|
||
echo "✅ Indexer sync workflow completed"
|
||
echo "📝 Changes pushed to automated-indexer-sync branch"
|