icebear0828 Claude Opus 4.6 commited on
Commit
8e4f44b
·
1 Parent(s): c784838

ci: auto-sync master → electron branch on push

Browse files

Automatically merges master into electron when master is pushed.
On conflict, creates a GitHub issue with manual resolution steps
(deduped by sync-conflict label).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. .github/workflows/sync-electron.yml +64 -0
.github/workflows/sync-electron.yml ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Sync master → electron
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ workflow_dispatch:
7
+
8
+ permissions:
9
+ contents: write
10
+ issues: write
11
+
12
+ jobs:
13
+ sync:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ with:
18
+ fetch-depth: 0
19
+
20
+ - name: Merge master into electron
21
+ run: |
22
+ git config user.name "github-actions[bot]"
23
+ git config user.email "github-actions[bot]@users.noreply.github.com"
24
+
25
+ git checkout electron
26
+ git merge origin/master --no-edit || {
27
+ # Conflict — abort and create issue
28
+ git merge --abort
29
+ echo "CONFLICT=true" >> "$GITHUB_ENV"
30
+ }
31
+
32
+ - name: Push if merged successfully
33
+ if: env.CONFLICT != 'true'
34
+ run: git push origin electron
35
+
36
+ - name: Create issue on conflict
37
+ if: env.CONFLICT == 'true'
38
+ run: |
39
+ # Check for existing open issue to avoid duplicates
40
+ EXISTING=$(gh issue list --label "sync-conflict" --state open --limit 1 --json number -q '.[0].number')
41
+ if [ -n "$EXISTING" ]; then
42
+ echo "Issue #$EXISTING already open, skipping"
43
+ exit 0
44
+ fi
45
+ gh issue create \
46
+ --title "electron 分支合并冲突需手动解决" \
47
+ --label "sync-conflict" \
48
+ --body "$(cat <<'EOF'
49
+ \`master\` → \`electron\` 自动合并失败,需要手动解决冲突。
50
+
51
+ ```bash
52
+ git checkout electron
53
+ git merge master
54
+ # 解决冲突(通常是 CHANGELOG.md)
55
+ git add .
56
+ git commit
57
+ git push origin electron
58
+ ```
59
+
60
+ 触发 commit: ${{ github.sha }}
61
+ EOF
62
+ )"
63
+ env:
64
+ GH_TOKEN: ${{ github.token }}