forked from zingolabs/zingo-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
96 lines (80 loc) · 3.15 KB
/
Copy pathupstream-sync.yml
File metadata and controls
96 lines (80 loc) · 3.15 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
name: Sync with Upstream
on:
schedule:
- cron: '0 9 * * 1' # Every Monday at 09:00 UTC
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Fetch upstream
run: |
git remote add upstream https://github.com/zingolabs/zingo-mobile.git
git fetch upstream dev --no-tags
- name: Check if sync needed
id: check
run: |
BEHIND=$(git rev-list HEAD..upstream/dev --count)
UPSTREAM_SHA=$(git rev-parse --short upstream/dev)
echo "behind=$BEHIND" >> "$GITHUB_OUTPUT"
echo "upstream_sha=$UPSTREAM_SHA" >> "$GITHUB_OUTPUT"
echo "Upstream is $BEHIND commits ahead (at $UPSTREAM_SHA)"
- name: Skip if up to date
if: steps.check.outputs.behind == '0'
run: echo "Fork is up to date with upstream. Nothing to do."
- name: Create sync branch
if: steps.check.outputs.behind != '0'
id: branch
run: |
BRANCH="upstream-sync/$(date +%Y-%m-%d)"
echo "name=$BRANCH" >> "$GITHUB_OUTPUT"
git checkout -b "$BRANCH"
CONFLICTS=false
if ! git merge upstream/dev --no-edit; then
CONFLICTS=true
git add -A
git commit -m "chore: upstream sync $(date +%Y-%m-%d) [conflicts - resolve before merging]"
fi
echo "conflicts=$CONFLICTS" >> "$GITHUB_OUTPUT"
git push origin "$BRANCH"
- name: Open pull request
if: steps.check.outputs.behind != '0'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
BRANCH="${{ steps.branch.outputs.name }}"
BEHIND="${{ steps.check.outputs.behind }}"
SHA="${{ steps.check.outputs.upstream_sha }}"
CONFLICTS="${{ steps.branch.outputs.conflicts }}"
if [ "$CONFLICTS" = "true" ]; then
TITLE="chore: upstream sync $(date +%Y-%m-%d) ⚠️ conflicts"
CONFLICT_NOTE="> ⚠️ **This PR contains merge conflicts** — resolve them before merging."
else
TITLE="chore: upstream sync $(date +%Y-%m-%d)"
CONFLICT_NOTE="> ✅ Clean merge — no conflicts detected."
fi
gh pr create \
--title "$TITLE" \
--body "## Upstream Sync
$CONFLICT_NOTE
Automated weekly sync from [zingolabs/zingo-mobile](https://github.com/zingolabs/zingo-mobile). **${BEHIND} new upstream commits** (@ \`${SHA}\`).
### Checklist
- [ ] Review upstream changes for impact on the KeepKey integration
- [ ] Resolve conflict markers if present (see branch \`${BRANCH}\`)
- [ ] Verify CI passes
- [ ] Confirm KeepKey-specific files are untouched or intentionally updated
- [ ] Rebase active feature branches onto \`dev\` after merge" \
--draft \
--base dev \
--head "$BRANCH"