Skip to content

Commit 9ea07e3

Browse files
committed
Simplify sync: merge directly to dev, no PRs needed
1 parent 41df388 commit 9ea07e3

1 file changed

Lines changed: 8 additions & 87 deletions

File tree

.github/workflows/upstream-sync.yml

Lines changed: 8 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ jobs:
1010
runs-on: ubuntu-latest
1111
permissions:
1212
contents: write
13-
pull-requests: write
1413

1514
steps:
1615
- uses: actions/checkout@v4
@@ -35,97 +34,19 @@ jobs:
3534
echo "behind=$BEHIND" >> $GITHUB_OUTPUT
3635
echo "$BEHIND new commits from upstream"
3736
38-
- name: Delete old sync branches
37+
- name: Merge upstream into dev
3938
if: steps.check.outputs.behind != '0'
4039
run: |
41-
git push origin --delete upstream-sync/$(date +%Y-%m-%d) 2>/dev/null || true
42-
43-
- name: Create sync branch and merge
44-
if: steps.check.outputs.behind != '0'
45-
id: merge
46-
run: |
47-
BRANCH="upstream-sync/$(date +%Y-%m-%d)"
48-
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
49-
git checkout -b "$BRANCH" dev
40+
# Try clean merge first
5041
if git merge upstream/main --no-edit; then
51-
echo "clean=true" >> $GITHUB_OUTPUT
42+
echo "Clean merge — no conflicts"
5243
else
53-
echo "clean=false" >> $GITHUB_OUTPUT
44+
echo "Conflicts found — resolving with ours strategy (keeping our changes)"
45+
git merge --abort
46+
git merge upstream/main --no-edit -X ours
5447
fi
5548
56-
- name: List conflicts if any
57-
if: steps.check.outputs.behind != '0' && steps.merge.outputs.clean == 'false'
58-
id: conflicts
59-
run: |
60-
CONFLICT_FILES=$(git diff --name-only --diff-filter=U | sort)
61-
CONFLICT_COUNT=$(echo "$CONFLICT_FILES" | wc -l | tr -d ' ')
62-
echo "count=$CONFLICT_COUNT" >> $GITHUB_OUTPUT
63-
echo "files<<EOF" >> $GITHUB_OUTPUT
64-
echo "$CONFLICT_FILES" >> $GITHUB_OUTPUT
65-
echo "EOF" >> $GITHUB_OUTPUT
66-
echo "Conflicting files:"
67-
echo "$CONFLICT_FILES"
68-
# Abort merge so PR shows the diff clearly
69-
git merge --abort
70-
# Re-merge with ours strategy for conflicting files to create a pushable branch
71-
git merge upstream/main --no-edit -X ours || true
72-
73-
- name: Push sync branch
49+
- name: Push to dev
7450
if: steps.check.outputs.behind != '0'
7551
run: |
76-
git push -u origin "${{ steps.merge.outputs.branch }}" --force
77-
78-
- name: Create PR (clean merge)
79-
if: steps.check.outputs.behind != '0' && steps.merge.outputs.clean == 'true'
80-
env:
81-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82-
run: |
83-
BEHIND=${{ steps.check.outputs.behind }}
84-
gh pr create \
85-
--title "[Upstream Sync] $BEHIND commits — clean merge" \
86-
--body "$(cat <<'BODY'
87-
## Upstream Sync
88-
89-
**$BEHIND** new commits from [claw-code](https://github.com/ultraworkers/claw-code) main.
90-
91-
Clean merge — no conflicts. Review and merge when ready.
92-
BODY
93-
)" \
94-
--base dev
95-
96-
- name: Create PR (with conflicts)
97-
if: steps.check.outputs.behind != '0' && steps.merge.outputs.clean == 'false'
98-
env:
99-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
100-
run: |
101-
BEHIND=${{ steps.check.outputs.behind }}
102-
CONFLICTS="${{ steps.conflicts.outputs.count }}"
103-
FILES="${{ steps.conflicts.outputs.files }}"
104-
gh pr create \
105-
--title "[Upstream Sync] $BEHIND commits — $CONFLICTS conflicts" \
106-
--body "$(cat <<BODY
107-
## Upstream Sync
108-
109-
**$BEHIND** new commits from [claw-code](https://github.com/ultraworkers/claw-code) main.
110-
111-
### Conflicts need manual resolution
112-
113-
The following files have merge conflicts (resolved with \`ours\` strategy — your version kept):
114-
115-
$(echo "$FILES" | sed 's/^/- `/' | sed 's/$/`/')
116-
117-
**To resolve properly:**
118-
\`\`\`bash
119-
git fetch origin ${{ steps.merge.outputs.branch }}
120-
git checkout ${{ steps.merge.outputs.branch }}
121-
git fetch upstream main # if not already added
122-
git merge --abort 2>/dev/null
123-
git reset --hard origin/dev
124-
git merge upstream/main
125-
# Resolve conflicts manually, then:
126-
git add -A && git commit
127-
git push --force origin ${{ steps.merge.outputs.branch }}
128-
\`\`\`
129-
BODY
130-
)" \
131-
--base dev
52+
git push origin dev

0 commit comments

Comments
 (0)