Skip to content

Commit 860b9a6

Browse files
Agent Communication MCP Serverclaude
andcommitted
fix: auto-sync workflow to properly pull from main branch
- Fixed workflow trigger to use correct workflow names (Automated Release, Automated Publication) - Added trigger on direct pushes to main branch - Improved merge logic with proper fetch and up-to-date checking - Enhanced status reporting for already synchronized branches - Better commit messages for auto-sync merges 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 4a34d5d commit 860b9a6

File tree

1 file changed

+50
-12
lines changed

1 file changed

+50
-12
lines changed

.github/workflows/auto-sync-test-branch.yml

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
name: Auto-Sync Test Branch
22

33
on:
4-
# Trigger after successful merge to main, after semver workflows complete
4+
# Trigger after successful release or publication workflows
55
workflow_run:
6-
workflows: ["Release Workflow"]
6+
workflows: ["Automated Release", "Automated Publication"]
77
types:
88
- completed
99
branches: [main]
10-
10+
11+
# Also trigger on direct pushes to main (for hotfixes or manual commits)
12+
push:
13+
branches: [main]
14+
1115
# Manual trigger for testing and maintenance
1216
workflow_dispatch:
1317
inputs:
@@ -121,22 +125,46 @@ jobs:
121125
if: steps.validation.outputs.VALIDATION_ISSUES != 'true' || github.event.inputs.force_sync == 'true'
122126
run: |
123127
echo "Proceeding with test branch synchronization..."
124-
128+
129+
# Fetch latest changes from both branches
130+
git fetch origin main:main --force
131+
git fetch origin test:test --force
132+
125133
# Switch to test branch
126134
git checkout test
127-
git pull origin test
128-
135+
136+
# Show current status
137+
echo "Current test branch commit:"
138+
git log --oneline -1
139+
echo "Latest main branch commit:"
140+
git log --oneline main -1
141+
142+
# Check if test is already up to date with main
143+
if git merge-base --is-ancestor main test; then
144+
echo "Test branch is already up to date with main"
145+
echo "ALREADY_UP_TO_DATE=true" >> $GITHUB_OUTPUT
146+
exit 0
147+
fi
148+
129149
# Attempt merge with main
130-
if git merge origin/main --no-edit; then
150+
if git merge main --no-edit -m "chore: auto-sync test branch with main
151+
152+
Automated synchronization of test branch with latest main branch changes.
153+
154+
🤖 Generated by Auto-Sync workflow run #${{ github.run_number }}"; then
131155
echo "MERGE_SUCCESS=true" >> $GITHUB_OUTPUT
132156
echo "Merge completed successfully"
157+
158+
# Show what was merged
159+
echo "Changes merged from main:"
160+
git log --oneline test^..test
133161
else
134162
echo "MERGE_CONFLICT=true" >> $GITHUB_OUTPUT
135163
echo "Merge conflicts detected"
136-
164+
137165
# Get conflict files for reporting
138166
git status --porcelain | grep "^UU" | cut -c4- > conflict_files.txt || echo "No conflict files detected"
139-
167+
140168
# Abort the merge
141169
git merge --abort
142170
fi
@@ -201,12 +229,22 @@ jobs:
201229
echo "## Auto-Sync Summary" >> $GITHUB_STEP_SUMMARY
202230
echo "- **Trigger**: ${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY
203231
echo "- **Main branch validation**: ${{ steps.validation.outputs.VALIDATION_ISSUES == 'true' && '❌ Failed' || '✅ Passed' }}" >> $GITHUB_STEP_SUMMARY
204-
echo "- **Sync attempt**: ${{ steps.sync.outputs.MERGE_SUCCESS == 'true' && '✅ Success' || steps.sync.outputs.MERGE_CONFLICT == 'true' && '⚠️ Conflicts' || '⏭️ Skipped' }}" >> $GITHUB_STEP_SUMMARY
205-
232+
233+
# Determine sync status
234+
if [ "${{ steps.sync.outputs.ALREADY_UP_TO_DATE }}" == "true" ]; then
235+
echo "- **Sync status**: ✅ Already up to date" >> $GITHUB_STEP_SUMMARY
236+
elif [ "${{ steps.sync.outputs.MERGE_SUCCESS }}" == "true" ]; then
237+
echo "- **Sync status**: ✅ Successfully synchronized" >> $GITHUB_STEP_SUMMARY
238+
elif [ "${{ steps.sync.outputs.MERGE_CONFLICT }}" == "true" ]; then
239+
echo "- **Sync status**: ⚠️ Merge conflicts detected" >> $GITHUB_STEP_SUMMARY
240+
else
241+
echo "- **Sync status**: ⏭️ Skipped (validation issues)" >> $GITHUB_STEP_SUMMARY
242+
fi
243+
206244
if [ "${{ steps.validation.outputs.ANY_TYPES_COUNT }}" -gt 0 ]; then
207245
echo "- **'any' types detected**: ${{ steps.validation.outputs.ANY_TYPES_COUNT }}" >> $GITHUB_STEP_SUMMARY
208246
fi
209-
247+
210248
if [ "${{ steps.sync.outputs.MERGE_CONFLICT }}" == "true" ]; then
211249
echo "- **Manual intervention required**: Merge conflicts need resolution" >> $GITHUB_STEP_SUMMARY
212250
fi

0 commit comments

Comments
 (0)