-
Notifications
You must be signed in to change notification settings - Fork 45
118 lines (104 loc) · 4.18 KB
/
branch-sync.yml
File metadata and controls
118 lines (104 loc) · 4.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
name: Branch Synchronization
on:
push:
branches: [ main ]
workflow_dispatch:
inputs:
sync_direction:
description: 'Sync direction'
required: true
default: 'main-to-remote'
type: choice
options:
- main-to-remote
- remote-to-main
- bidirectional
jobs:
sync-branches:
name: Sync Branches
runs-on: ubuntu-latest
if: github.repository_owner == 'gensecaihq'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Git
run: |
git config --global user.name 'GitHub Actions'
git config --global user.email 'actions@github.com'
- name: Fetch all branches
run: |
git fetch origin
- name: Check branch existence
id: branches
run: |
if git ls-remote --exit-code --heads origin mcp-remote >/dev/null 2>&1; then
echo "mcp_remote_exists=true" >> $GITHUB_OUTPUT
git checkout -b mcp-remote origin/mcp-remote
git checkout main
else
echo "mcp_remote_exists=false" >> $GITHUB_OUTPUT
echo "::notice::mcp-remote branch does not exist yet"
fi
- name: Check for version management tools
run: |
if [ -f tools/branch-sync.py ]; then
echo "Version management tools found"
python3 tools/branch-sync.py status
else
echo "Version management tools not found"
fi
- name: Create sync report
run: |
echo "# Branch Sync Report" >> $GITHUB_STEP_SUMMARY
echo "## Current Status" >> $GITHUB_STEP_SUMMARY
echo "- Main branch: $(git rev-parse --short HEAD)" >> $GITHUB_STEP_SUMMARY
if [ "${{ steps.branches.outputs.mcp_remote_exists }}" == "true" ]; then
echo "- MCP-Remote branch: $(git rev-parse --short origin/mcp-remote)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "## Differences" >> $GITHUB_STEP_SUMMARY
echo "### Main → MCP-Remote" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
git log HEAD..origin/mcp-remote --oneline | head -10 >> $GITHUB_STEP_SUMMARY || echo "No differences" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "### MCP-Remote → Main" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
git log origin/mcp-remote..HEAD --oneline | head -10 >> $GITHUB_STEP_SUMMARY || echo "No differences" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
else
echo "- MCP-Remote branch: **does not exist**" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "> **Note:** Create the mcp-remote branch when ready to support MCP remote transport mode." >> $GITHUB_STEP_SUMMARY
fi
- name: Sync based on input
if: github.event_name == 'workflow_dispatch' && steps.branches.outputs.mcp_remote_exists == 'true'
run: |
case "${{ github.event.inputs.sync_direction }}" in
main-to-remote)
echo "Syncing main → mcp-remote (shared components only)"
# Cherry-pick specific commits or merge shared components
;;
remote-to-main)
echo "Syncing mcp-remote → main (STDIO-compatible changes only)"
# Cherry-pick STDIO-compatible changes
;;
bidirectional)
echo "Bidirectional sync (careful merge)"
# Merge compatible changes both ways
;;
esac
- name: Version check
run: |
echo "## Version Information" >> $GITHUB_STEP_SUMMARY
echo "### Main Branch" >> $GITHUB_STEP_SUMMARY
if [ -f pyproject.toml ]; then
echo "Version: $(grep '^version' pyproject.toml | cut -d'"' -f2)" >> $GITHUB_STEP_SUMMARY
fi
if [ "${{ steps.branches.outputs.mcp_remote_exists }}" == "true" ]; then
echo "### MCP-Remote Branch" >> $GITHUB_STEP_SUMMARY
git checkout mcp-remote
if [ -f pyproject.toml ]; then
echo "Version: $(grep '^version' pyproject.toml | cut -d'"' -f2)" >> $GITHUB_STEP_SUMMARY
fi
fi