Skip to content
Open
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: 12 additions & 29 deletions .github/workflows/build_loop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -233,43 +233,26 @@ jobs:
vars.SCHEDULED_SYNC != 'false' && github.repository_owner != 'LoopKit' && needs.check_latest_from_upstream.outputs.ABORT_SYNC == 'false'
id: sync
run: |
set -e
echo "Starting upstream sync process..."
# First try the standard fork sync action
set +e
echo "Attempting standard fork sync..."

# 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
# Use the fork sync action first
gh extension install aormsby/gh-fork-sync || echo "Extension already installed"

# 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
# Try fork sync with the action approach first
sync_result=0

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

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

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

Expand Down