Skip to content

Update qBittorrent Clients #8

Update qBittorrent Clients

Update qBittorrent Clients #8

name: Update qBittorrent Clients
on:
schedule:
# Run bi-weekly on the 1st and 15th at 6 AM UTC
- cron: '0 6 1,15 * *'
workflow_dispatch: {} # Allow manual triggering
jobs:
update-clients:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
# Fetch full history for fork compatibility
fetch-depth: 0
# Ensure we use the current repository context
repository: ${{ github.repository }}
- name: Setup cache for downloads
uses: actions/cache@v4
with:
path: ~/.cache/qbt_analyzer
key: qbt-cache-${{ runner.os }}-${{ hashFiles('*/qbittorrent_analyzer.sh') }}
restore-keys: |
qbt-cache-${{ runner.os }}-
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y curl jq
- name: Generate Missing Client Files
id: generate
run: |
chmod +x ./scripts/bittorrent-client-update-detector/qbittorrent_analyzer.sh
./scripts/bittorrent-client-update-detector/qbittorrent_analyzer.sh --batch-update resources/clients
- name: Check for changes
id: check_changes
run: |
echo "Checking for changes in working directory..."
git status --porcelain > git_status.txt
if [[ -s git_status.txt ]]; then
echo "changes=true" >> $GITHUB_OUTPUT
echo "Changed files detected:"
cat git_status.txt
# Check specifically for client file changes (not script changes)
if grep -q "resources/clients/" git_status.txt; then
echo "client_changes=true" >> $GITHUB_OUTPUT
echo "Client file changes detected"
else
echo "client_changes=false" >> $GITHUB_OUTPUT
echo "No client file changes detected (possibly only script changes)"
fi
else
echo "changes=false" >> $GITHUB_OUTPUT
echo "client_changes=false" >> $GITHUB_OUTPUT
echo "No changes detected"
fi
- name: Configure Git (Fork Compatible)
if: steps.check_changes.outputs.changes == 'true'
run: |
echo "Configuring Git for fork repository..."
# Set git configuration
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
# Check if this is a fork and configure appropriately
if [[ "${{ github.repository }}" != "anthonyraymond/joal" ]]; then
echo "Running in fork: ${{ github.repository }}"
# For forks, ensure we have the right remote configured
git remote set-url origin https://github.com/${{ github.repository }}.git || true
echo "Set remote URL for fork"
fi
# Verify git configuration
git config --list --local
- name: Add files and commit
if: steps.check_changes.outputs.changes == 'true'
run: |
echo "Adding files to git..."
# Add client files only (ignore script changes)
git add resources/clients/ || echo "No client files to add"
# Check if there are any staged changes
if git diff --cached --quiet; then
echo "No staged changes to commit"
echo "skip_commit=true" >> $GITHUB_OUTPUT
else
echo "Staging changes for commit..."
git diff --cached --name-only
# Use a commit template that works across forks
TIMESTAMP=$(date -u '+%Y-%m-%d %H:%M:%S UTC')
COMMIT_MSG="Auto-update: Added missing qBittorrent client files
- Generated client configurations for newly released versions
- Updated by GitHub Action on ${TIMESTAMP}
- Repository: ${{ github.repository }}"
git commit -m "${COMMIT_MSG}"
echo "skip_commit=false" >> $GITHUB_OUTPUT
fi
- name: Push change(s)
if: steps.check_changes.outputs.changes == 'true' && steps.add_files.outputs.skip_commit != 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Attempting to push changes..."
# Configure git to use GitHub token for authentication
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git
# Try to push with proper error handling
if git push origin ${{ github.ref_name }} 2>/dev/null; then
echo "✅ Successfully pushed changes to repository"
elif git push origin master 2>/dev/null; then
echo "✅ Successfully pushed changes to master branch"
else
echo "⚠️ Could not push changes - this might be expected in fork scenarios"
echo "Changes are available locally for manual review"
fi
- name: Debug git status (Fork Analysis)
if: failure() || steps.check_changes.outputs.changes == 'true'
run: |
echo "=== Git Debug Information ==="
echo "Repository: ${{ github.repository }}"
echo "Ref: ${{ github.ref_name }}"
echo "Current branch: $(git branch --show-current)"
echo "Remote URL: $(git remote get-url origin)"
echo "Git status:"
git status
echo "Recent commits:"
git log --oneline -5
echo "=== End Debug Info ==="
- name: Summary
run: |
echo "=== Workflow Summary ==="
echo "Repository: ${{ github.repository }}"
echo "Branch: ${{ github.ref_name }}"
echo "Trigger: ${{ github.event_name }}"
if [[ "${{ steps.check_changes.outputs.changes }}" == "true" ]]; then
if [[ "${{ steps.check_changes.outputs.client_changes }}" == "true" ]]; then
echo "✅ Successfully updated client files"
if [[ "${{ steps.add_files.outputs.skip_commit }}" != "true" ]]; then
echo "✅ Changes committed and pushed"
else
echo "ℹ️ No client file changes to commit"
fi
else
echo "⚠️ Script modifications detected - no client file changes"
echo "Review script changes manually through GitHub web interface"
fi
else
echo "ℹ️ No new qBittorrent versions found - all client files are up to date"
fi
echo "=== Workflow Complete ==="