Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix: Update sync workflow to use single PR instead of creating multiple

LearningCircuitf54bbcd86aa4
diff --git a/.github/workflows/sync-main-to-dev.yml b/.github/workflows/sync-main-to-dev.yml
index 7da44d5a3f..85d5cdd2c8 100644
--- a/.github/workflows/sync-main-to-dev.yml
+++ b/.github/workflows/sync-main-to-dev.yml
@@ -59,20 +59,26 @@ jobs:
echo "Sync needed: main ($MAIN_COMMIT) differs from dev ($DEV_COMMIT)"
fi
- - name: Create sync branch
+ - name: Create or update sync branch
if: steps.check_sync.outputs.sync_needed == 'true'
id: create_branch
run: |
- # Generate unique branch name with timestamp
- TIMESTAMP=$(date +%Y%m%d-%H%M%S)
- BRANCH_NAME="sync-main-to-dev-$TIMESTAMP"
+ # Use fixed branch name for updates
+ BRANCH_NAME="sync-main-to-dev"
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
- # Create new branch from main
- git checkout -b $BRANCH_NAME origin/main
-
- # Push the new branch
- git push origin $BRANCH_NAME
+ # Check if branch exists on remote
+ if git ls-remote --heads origin $BRANCH_NAME | grep -q $BRANCH_NAME; then
+ echo "Branch exists, will update it"
+ git fetch origin $BRANCH_NAME
+ git checkout -B $BRANCH_NAME origin/main
+ # Force push to update the branch
+ git push -f origin $BRANCH_NAME
+ else
+ echo "Creating new branch"
+ git checkout -b $BRANCH_NAME origin/main
+ git push origin $BRANCH_NAME
+ fi
- name: Attempt merge and handle conflicts
if: steps.check_sync.outputs.sync_needed == 'true'
@@ -106,7 +112,7 @@ jobs:
# Push the merged changes
git push origin $BRANCH_NAME
- - name: Create Pull Request
+ - name: Create or Update Pull Request
if: steps.check_sync.outputs.sync_needed == 'true'
uses: actions/github-script@v7
with:
@@ -115,11 +121,12 @@ jobs:
const branchName = '${{ steps.create_branch.outputs.branch_name }}';
const hasConflicts = '${{ steps.merge_attempt.outputs.merge_conflicts }}' === 'true';
const conflictedFiles = `${{ steps.merge_attempt.outputs.conflicted_files }}`.split('\n').filter(f => f.trim());
+ const timestamp = new Date().toISOString();
let title, body;
if (hasConflicts) {
- title = `🚨 Sync main to dev (CONFLICTS) - ${branchName}`;
+ title = `🚨 Sync main to dev (CONFLICTS)`;
body = `## ⚠️ Merge Conflicts Detected
This automated sync from main to dev has **merge conflicts** that require manual resolution.
@@ -139,9 +146,12 @@ jobs:
- Preserving all dev branch improvements
- Maintaining compatibility between branches
- **⚡ Action Required:** Please resolve conflicts manually and update this PR.`;
+ **⚡ Action Required:** Please resolve conflicts manually and update this PR.
+
+ ---
+ *Last updated: ${timestamp}*`;
} else {
- title = `✅ Sync main to dev - ${branchName}`;
+ title = `✅ Sync main to dev`;
body = `## Summary
This is an automated sync of main branch changes into dev.
@@ -151,26 +161,75 @@ jobs:
- Ready for review and merge
### Automated Process:
- - ✅ Created sync branch from main
+ - ✅ Created/updated sync branch from main
- ✅ Successfully merged dev branch
- ✅ No conflicts detected
- ✅ Ready for final review
- This ensures main and dev branches stay synchronized automatically.`;
+ This ensures main and dev branches stay synchronized automatically.
+
+ ---
+ *Last updated: ${timestamp}*`;
}
- const { data: pr } = await github.rest.pulls.create({
+ // Check if a PR already exists for this branch
+ const { data: existingPRs } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
- title: title,
- head: branchName,
- base: 'dev',
- body: body
+ state: 'open',
+ head: `${context.repo.owner}:${branchName}`,
+ base: 'dev'
});
- console.log(`Created PR #${pr.number}: ${pr.html_url}`);
+ let pr;
+ if (existingPRs.length > 0) {
+ // Update existing PR
+ pr = existingPRs[0];
+ console.log(`Updating existing PR #${pr.number}`);
+
+ await github.rest.pulls.update({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ pull_number: pr.number,
+ title: title,
+ body: body
+ });
+
+ console.log(`Updated PR #${pr.number}: ${pr.html_url}`);
+ } else {
+ // Create new PR
+ const { data: newPr } = await github.rest.pulls.create({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ title: title,
+ head: branchName,
+ base: 'dev',
+ body: body
+ });
+ pr = newPr;
+ console.log(`Created PR #${pr.number}: ${pr.html_url}`);
+ }
+
+ // Update labels (remove old ones and add new ones)
+ const currentLabels = pr.labels.map(l => l.name);
+ const labelsToRemove = currentLabels.filter(l => l === 'sync' || l === 'conflicts' || l === 'auto-merge');
+
+ if (labelsToRemove.length > 0) {
+ for (const label of labelsToRemove) {
+ try {
+ await github.rest.issues.removeLabel({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ issue_number: pr.number,
+ name: label
+ });
+ } catch (e) {
+ console.log(`Could not remove label ${label}: ${e.message}`);
+ }
+ }
+ }
- // Add labels
+ // Add appropriate labels
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,