Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 29 additions & 12 deletions .github/workflows/build_loop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -233,26 +233,43 @@ jobs:
vars.SCHEDULED_SYNC != 'false' && github.repository_owner != 'LoopKit' && needs.check_latest_from_upstream.outputs.ABORT_SYNC == 'false'
id: sync
run: |
# First try the standard fork sync action
set +e
echo "Attempting standard fork sync..."
set -e
echo "Starting upstream sync process..."

# Use the fork sync action first
gh extension install aormsby/gh-fork-sync || echo "Extension already installed"
# Try to install gh-fork-sync extension if not already installed
if ! gh extension list | grep -q "aormsby/gh-fork-sync"; then
echo "Installing gh-fork-sync extension..."
gh extension install aormsby/gh-fork-sync || echo "Failed to install extension"
fi

# Try fork sync with the action approach first
sync_result=0
# Try gh-fork-sync first if available
if gh extension list | grep -q "aormsby/gh-fork-sync"; then
echo "Using gh-fork-sync extension..."
set +e
gh fork-sync --upstream "$UPSTREAM_REPO" --branch "$TARGET_BRANCH"
sync_result=$?
set -e

if [ $sync_result -eq 0 ]; then
echo "Fork sync completed successfully"
echo "has_new_commits=true" >> $GITHUB_OUTPUT
exit 0
else
echo "Fork sync failed, falling back to custom script..."
fi
else
echo "gh-fork-sync not available, using custom script..."
fi

# If the action approach fails, use our custom script
echo "Using custom sync script to handle potential conflicts..."
# Use our custom script as fallback or primary method
echo "Using custom sync script to handle merge conflicts..."
bash ./Scripts/sync_with_upstream.sh
sync_result=$?

if [ $sync_result -eq 0 ]; then
echo "Sync completed successfully"
echo "has_new_commits=true" >> $GITHUB_OUTPUT
echo "Custom sync completed successfully"
else
echo "Sync failed"
echo "Custom sync failed"
exit 1
fi
env:
Expand Down
8 changes: 6 additions & 2 deletions Scripts/sync_with_upstream.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,14 @@ fi

# Attempt merge with upstream
echo -e "${YELLOW}Attempting to merge upstream changes${NC}"
if git merge "upstream/$UPSTREAM_BRANCH" --no-edit; then
if git merge "upstream/$UPSTREAM_BRANCH" --no-edit --allow-unrelated-histories; then
echo -e "${GREEN}Successfully merged upstream changes without conflicts${NC}"
echo -e "${GREEN}Pushing changes to origin${NC}"
git push origin "$TARGET_BRANCH"
if [ "$GH_PAT" = "dummy" ]; then
echo -e "${YELLOW}Skipping push (dummy PAT provided)${NC}"
else
git push origin "$TARGET_BRANCH"
fi
exit 0
fi

Expand Down