From bf9b7d0311fe1a951c8bee21c870b809e94d8f72 Mon Sep 17 00:00:00 2001 From: gavrielc Date: Wed, 25 Mar 2026 00:39:20 +0200 Subject: [PATCH] fix: auto-resolve package-lock/badge/version conflicts in fork sync The fork-sync and merge-forward workflows were failing on every run because package-lock.json, package.json (version), and badge.svg always conflict between upstream and forks. These are always safe to take from upstream/main. Now auto-resolves these trivial conflicts and only fails on real code conflicts. Co-Authored-By: Claude Opus 4.6 (1M context) --- .github/workflows/fork-sync-skills.yml | 57 ++++++++++++++++++---- .github/workflows/merge-forward-skills.yml | 25 ++++++++-- 2 files changed, 68 insertions(+), 14 deletions(-) diff --git a/.github/workflows/fork-sync-skills.yml b/.github/workflows/fork-sync-skills.yml index 8d25ee2..0d8433e 100644 --- a/.github/workflows/fork-sync-skills.yml +++ b/.github/workflows/fork-sync-skills.yml @@ -62,14 +62,34 @@ jobs: # Merge upstream main into fork's main if ! git merge upstream/main --no-edit; then - echo "::error::Failed to merge upstream/main into fork main — conflicts detected" - git merge --abort - echo "synced=false" >> "$GITHUB_OUTPUT" - echo "sync_failed=true" >> "$GITHUB_OUTPUT" - exit 0 + # Auto-resolve trivial conflicts (lockfile, badge, package.json version) + CONFLICTED=$(git diff --name-only --diff-filter=U) + AUTO_RESOLVABLE=true + for f in $CONFLICTED; do + case "$f" in + package-lock.json|package.json|repo-tokens/badge.svg) + git checkout --theirs "$f" + git add "$f" + ;; + *) + AUTO_RESOLVABLE=false + ;; + esac + done + + if [ "$AUTO_RESOLVABLE" = false ]; then + echo "::error::Failed to merge upstream/main into fork main — non-trivial conflicts detected" + git merge --abort + echo "synced=false" >> "$GITHUB_OUTPUT" + echo "sync_failed=true" >> "$GITHUB_OUTPUT" + exit 0 + fi + + git commit --no-edit + echo "Auto-resolved lockfile/badge/version conflicts" fi - # Validate build + # Regenerate lockfile to match merged package.json npm ci if ! npm run build; then echo "::error::Build failed after merging upstream/main" @@ -115,10 +135,27 @@ jobs: git checkout -B "$BRANCH" "origin/$BRANCH" if ! git merge main --no-edit; then - echo "::warning::Merge conflict in $BRANCH" - git merge --abort - FAILED="$FAILED $SKILL_NAME" - continue + # Auto-resolve trivial conflicts + CONFLICTED=$(git diff --name-only --diff-filter=U) + CAN_AUTO=true + for f in $CONFLICTED; do + case "$f" in + package-lock.json|package.json|repo-tokens/badge.svg) + git checkout --theirs "$f" + git add "$f" + ;; + *) + CAN_AUTO=false + ;; + esac + done + if [ "$CAN_AUTO" = false ]; then + echo "::warning::Merge conflict in $BRANCH" + git merge --abort + FAILED="$FAILED $SKILL_NAME" + continue + fi + git commit --no-edit fi # Check if there's anything new to push diff --git a/.github/workflows/merge-forward-skills.yml b/.github/workflows/merge-forward-skills.yml index 093130a..b648eb1 100644 --- a/.github/workflows/merge-forward-skills.yml +++ b/.github/workflows/merge-forward-skills.yml @@ -52,10 +52,27 @@ jobs: # Attempt merge if ! git merge main --no-edit; then - echo "::warning::Merge conflict in $BRANCH" - git merge --abort - FAILED="$FAILED $SKILL_NAME" - continue + # Auto-resolve trivial conflicts + CONFLICTED=$(git diff --name-only --diff-filter=U) + CAN_AUTO=true + for f in $CONFLICTED; do + case "$f" in + package-lock.json|package.json|repo-tokens/badge.svg) + git checkout --theirs "$f" + git add "$f" + ;; + *) + CAN_AUTO=false + ;; + esac + done + if [ "$CAN_AUTO" = false ]; then + echo "::warning::Merge conflict in $BRANCH" + git merge --abort + FAILED="$FAILED $SKILL_NAME" + continue + fi + git commit --no-edit fi # Check if there's anything new to push