🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🔧 ci: optimize sync-main-to-canary to merge directly when no conflicts (#12306)
Inneibaf0b56f64b8
diff --git a/.github/workflows/sync-main-to-canary.yaml b/.github/workflows/sync-main-to-canary.yamlindex a2e9a97a09b..904bed58218 100644--- a/.github/workflows/sync-main-to-canary.yaml+++ b/.github/workflows/sync-main-to-canary.yaml@@ -23,24 +23,84 @@ jobs:git config --global user.name 'lobehubbot'git config --global user.email '[email protected]'- - name: Prepare sync branch- id: branch- run: |- echo "SYNC_BRANCH_MAIN_CANARY=sync/main-to-canary-$(date +'%Y%m%d')" >> $GITHUB_ENV-- name: Sync main to canaryif: github.ref == 'refs/heads/main'run: |- # Sync main to canary- git checkout main- SYNC_BRANCH_CANARY=${{ env.SYNC_BRANCH_MAIN_CANARY }}- git checkout -B $SYNC_BRANCH_CANARY- DIFF=$(git diff origin/canary...)- if [ -z "$DIFF" ]; then- echo "No changes to sync"- exit 0+ # Find existing open sync PR by head branch prefix+ EXISTING_PR=$(gh pr list --base canary --state open --json number,headRefName \+ --jq '[.[] | select(.headRefName | startswith("sync/main-to-canary-"))][0] // empty')+ EXISTING_PR_NUMBER=$(echo "$EXISTING_PR" | jq -r '.number // empty' 2>/dev/null)+ EXISTING_BRANCH=$(echo "$EXISTING_PR" | jq -r '.headRefName // empty' 2>/dev/null)++ git checkout canary+ git pull origin canary++ # Try merge, detect conflicts+ if git merge origin/main --no-edit; then+ # No conflicts, check if there are actual changes+ if [ "$(git rev-parse HEAD)" = "$(git rev-parse origin/canary)" ]; then+ echo "No changes to sync"+ exit 0+ fi+ echo "Merge succeeded, pushing directly"+ if git push origin canary; then+ # Close stale sync PR if direct push succeeded+ if [ -n "$EXISTING_PR_NUMBER" ]; then+ gh pr close "$EXISTING_PR_NUMBER" --comment "Superseded by direct push." --delete-branch || true+ fi+ exit 0+ fi++ # Direct push failed (e.g. non-fast-forward race), fall back to PR+ echo "Direct push failed, falling back to PR"+ SYNC_BRANCH="sync/main-to-canary-$(date +'%Y%m%d')-${GITHUB_RUN_ID}"+ git checkout -B "$SYNC_BRANCH"+ git push origin "$SYNC_BRANCH" -f+ gh pr create \+ --base canary \+ --head "$SYNC_BRANCH" \+ --title "Sync main branch to canary branch" \+ --body "Automatic sync from main to canary. Direct push failed, please merge this PR." || true+ else+ echo "Merge conflicts detected, creating PR"+ git merge --abort++ if [ -n "$EXISTING_PR_NUMBER" ]; then+ # Existing conflict PR open — notify via comment, don't overwrite manual work+ gh pr comment "$EXISTING_PR_NUMBER" --body "New commits on \`main\`. Please pull latest \`origin/main\` into this branch to include them."+ echo "Commented on existing PR #$EXISTING_PR_NUMBER"+ else+ SYNC_BRANCH="sync/main-to-canary-$(date +'%Y%m%d')-${GITHUB_RUN_ID}"+ git checkout -B "$SYNC_BRANCH" origin/canary+ # Attempt merge main, commit conflict markers if unresolved+ if ! git merge origin/main --no-edit; then+ git add -A+ git commit --no-edit -m "chore: merge main into canary (has conflicts to resolve)"+ fi+ git push origin "$SYNC_BRANCH" -f++ printf '%s\n' \+ 'Automatic sync from main to canary. Merge conflicts detected.' \+ '' \+ '**Resolution steps:**' \+ '```bash' \+ 'git fetch origin' \+ "git checkout $SYNC_BRANCH" \+ 'git merge origin/main' \+ '# Resolve conflicts' \+ 'git add -A && git commit' \+ 'git push' \+ '```' \+ '' \+ '> Do NOT merge canary into a main-based branch — always merge main INTO the canary-based branch to keep a clean commit graph.' \+ > /tmp/pr-body.md++ gh pr create \+ --base canary \+ --head "$SYNC_BRANCH" \+ --title "Sync main branch to canary branch" \+ --body-file /tmp/pr-body.md+ fifi- git push origin $SYNC_BRANCH_CANARY -f- gh pr create --base canary --head $SYNC_BRANCH_CANARY --title "Sync main branch to canary branch" --body "Automatic sync" || exit 0env:GH_TOKEN: ${{ secrets.GH_TOKEN }}diff --git a/eslint.config.mjs b/eslint.config.mjsindex 66dfb055e9c..6397a257ef2 100644--- a/eslint.config.mjs+++ b/eslint.config.mjs@@ -1,6 +1,10 @@+import { fileURLToPath } from 'node:url';+import { eslint } from '@lobehub/lint';import { flat as mdxFlat } from 'eslint-plugin-mdx';+const tsconfigRootDir = fileURLToPath(new URL('.', import.meta.url));+export default eslint({ignores: [@@ -40,6 +44,13 @@ export default eslint(next: true,react: 'next',},+ {+ languageOptions: {+ parserOptions: {+ tsconfigRootDir,+ },+ },+ },// Global rule overrides{rules: {