From 1add4d97cf8e1b56d33971ac147abc8c59d631bb Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 20 Nov 2025 01:36:27 +0000 Subject: [PATCH] fix(workflow): Correct upstream sync to preserve custom files and push to stable Fixed two critical issues in the sync-upstream.yml workflow: 1. Wildcard conflict resolution: The previous logic used wildcards (profiles/*.yml) that overlapped with custom files (profiles/*Micro*.yml), causing custom files to be overwritten. Now uses a two-phase explicit merge strategy: - Phase 1: Accept all upstream changes - Phase 2: Explicitly restore custom files by exact path 2. Wrong push target: Changed from 'main || master' to 'stable' branch This ensures weekly syncs will now work correctly while preserving: - profiles/1080p Micro.yml, 720p Micro.yml - custom_formats/Micro Encode Tier 1/2/3.yml - regex_patterns/BONE.yml, ETHEL.yml, GalaxyRG.yml, TGx.yml - custom_formats/Foreign Release Groups.yml --- .github/workflows/sync-upstream.yml | 47 +++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml index 93c46b2..30bf8fb 100644 --- a/.github/workflows/sync-upstream.yml +++ b/.github/workflows/sync-upstream.yml @@ -32,24 +32,51 @@ jobs: run: | # Try to merge upstream changes git merge upstream/stable --no-edit --allow-unrelated-histories || { - echo "Merge conflict detected, attempting auto-resolution..." + echo "=== Merge conflict detected, applying custom merge strategy ===" - # Keep our custom files (Micro profiles and formats) - git checkout --ours profiles/*Micro*.yml custom_formats/*Micro*.yml regex_patterns/BONE.yml regex_patterns/GalaxyRG.yml regex_patterns/TGx.yml regex_patterns/ETHEL.yml 2>/dev/null || true - - # Keep their files for everything else - git checkout --theirs profiles/*.yml custom_formats/*.yml regex_patterns/*.yml 2>/dev/null || true - - # Add resolved files + # PHASE 1: Accept ALL upstream changes first + echo "Phase 1: Accepting all upstream changes..." + git checkout --theirs . git add -A + # PHASE 2: Restore our custom files explicitly + echo "Phase 2: Restoring custom files from our branch..." + + CUSTOM_FILES=( + "profiles/1080p Micro.yml" + "profiles/720p Micro.yml" + "custom_formats/Micro Encode Tier 1.yml" + "custom_formats/Micro Encode Tier 2.yml" + "custom_formats/Micro Encode Tier 3.yml" + "regex_patterns/BONE.yml" + "regex_patterns/ETHEL.yml" + "regex_patterns/GalaxyRG.yml" + "regex_patterns/TGx.yml" + "custom_formats/Foreign Release Groups.yml" + ) + + for file in "${CUSTOM_FILES[@]}"; do + if git cat-file -e HEAD:"$file" 2>/dev/null; then + echo " ✓ Preserving: $file" + git checkout --ours "$file" + git add "$file" + else + echo " ⚠ Not found in our branch: $file" + fi + done + # Complete the merge - git commit -m "chore(sync): Merge upstream changes from Dictionarry-Hub/database" || true + if git diff --cached --quiet; then + echo "No changes to commit after merge resolution" + else + echo "=== Committing merge ===" + git commit -m "chore(sync): Merge upstream changes while preserving custom Micro profiles and formats" + fi } - name: Push changes run: | - git push origin main || git push origin master + git push origin stable env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}