ArrProfiles/.github/workflows/sync-upstream.yml

90 lines
3.0 KiB
YAML

name: Sync Upstream
on:
schedule:
# Run weekly on Sundays at 2 AM UTC
- cron: '0 2 * * 0'
workflow_dispatch:
# Allow manual triggering
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Add upstream remote
run: |
git remote add upstream https://github.com/Dictionarry-Hub/database.git || true
git fetch upstream
- name: Sync from upstream stable branch
run: |
# Try to merge upstream changes
git merge upstream/stable --no-edit --allow-unrelated-histories || {
echo "=== Merge conflict detected, applying custom merge strategy ==="
# 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
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 stable
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create summary
run: |
echo "## Upstream Sync Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "✅ Successfully synced from upstream repository" >> $GITHUB_STEP_SUMMARY
echo "- Source: Dictionarry-Hub/database (stable branch)" >> $GITHUB_STEP_SUMMARY
echo "- Custom files preserved: Micro profiles and formats" >> $GITHUB_STEP_SUMMARY