Skip to content

Commit 92a8a82

Browse files
terafinclaude
andcommitted
ci: upgrade sync-upstream to v1.2.0 + auto-regen intarweb-dev
Adopt the canonical Model B sync workflow: rebase main onto upstream daily, then regenerate intarweb-dev = main + cherry-picks of every open PR from intarweb to upstream. Cron slot 45 (per portfolio table). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 342c31c commit 92a8a82

1 file changed

Lines changed: 56 additions & 18 deletions

File tree

Lines changed: 56 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
name: Sync from upstream
1+
name: Sync from upstream + auto-regen intarweb-dev
22

33
on:
44
schedule:
5-
- cron: '15 6 * * *' # daily — chains into publish-ghcr.yml on push
5+
- cron: '45 6 * * *' # daily — chains into publish-ghcr.yml on push
66
workflow_dispatch:
77

88
permissions:
99
contents: write
10+
pull-requests: read
1011

1112
jobs:
1213
sync:
@@ -21,29 +22,66 @@ jobs:
2122
- name: ⚙️ Configure git identity
2223
run: |
2324
git config user.email "actions@github.com"
24-
git config user.name "terafin sync bot"
25+
git config user.name "intarweb sync bot"
2526
2627
- name: 🔗 Add upstream remote
2728
run: git remote add upstream https://github.com/joeblack2k/RetroSaveManager.git
2829

29-
- name: 🔄 Fetch upstream
30-
run: git fetch upstream main --tags
30+
- name: 🔄 Fetch upstream + all fork branches
31+
run: |
32+
git fetch upstream main --tags
33+
git fetch origin --prune
34+
35+
- name: 🔁 Rebase main onto upstream
36+
run: |
37+
git checkout main
38+
git rebase upstream/main
39+
git push --force-with-lease origin main
3140
32-
- name: 📐 Show divergence (pre-rebase)
41+
- name: 🔍 Discover open PRs from intarweb to upstream
42+
id: prs
43+
env:
44+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3345
run: |
34-
echo " upstream/main: $(git log upstream/main --oneline -1)"
35-
echo " origin/main: $(git log origin/main --oneline -1)"
36-
echo " terafin commits on top:"
37-
git log --oneline upstream/main..HEAD | sed 's/^/ /' || true
46+
gh api "repos/joeblack2k/RetroSaveManager/pulls?state=open&per_page=100" \
47+
--jq '.[] | select(.head.repo.owner.login == "${{ github.repository_owner }}") | "\(.number) \(.head.ref) \(.title)"' \
48+
| sort -n > /tmp/prs.txt
49+
if [ ! -s /tmp/prs.txt ]; then
50+
echo " No open PRs from ${{ github.repository_owner }} to upstream — intarweb-dev will == main"
51+
else
52+
echo " Open PRs to cherry-pick onto intarweb-dev:"
53+
sed 's/^/ /' /tmp/prs.txt
54+
fi
3855
39-
- name: 🔁 Rebase fork commits onto upstream/main
40-
run: git rebase upstream/main
56+
- name: 🌿 Regenerate intarweb-dev = main + open-PR cherry-picks
57+
run: |
58+
git checkout -B intarweb-dev main
59+
while read num branch title; do
60+
[ -z "$num" ] && continue
61+
echo "::group::PR #$num — $branch ($title)"
62+
git fetch origin "$branch" || { echo " ✗ failed to fetch origin/$branch"; exit 1; }
63+
COMMITS=$(git log --reverse --format=%H "intarweb-dev..origin/$branch")
64+
if [ -z "$COMMITS" ]; then
65+
echo " - no unique commits — already on intarweb-dev (likely merged upstream); skipping"
66+
else
67+
for c in $COMMITS; do
68+
if ! git cherry-pick "$c"; then
69+
echo "::error::CONFLICT cherry-picking $c from PR #$num. intarweb-dev unchanged. Manual resolve required."
70+
git cherry-pick --abort || true
71+
exit 1
72+
fi
73+
done
74+
echo " ✓ applied $(echo "$COMMITS" | wc -w) commits from PR #$num"
75+
fi
76+
echo "::endgroup::"
77+
done < /tmp/prs.txt
4178
42-
- name: 📤 Push (force-with-lease)
43-
run: git push --force-with-lease origin main
79+
- name: 📤 Force-push intarweb-dev
80+
run: git push --force-with-lease origin intarweb-dev
4481

45-
- name: ✅ Show new state
82+
- name: ✅ Show final state
4683
run: |
47-
echo " new HEAD: $(git log --oneline -1)"
48-
echo " fork commits preserved on top:"
49-
git log --oneline upstream/main..HEAD | sed 's/^/ /' || true
84+
echo " main HEAD: $(git log main --oneline -1)"
85+
echo " intarweb-dev HEAD: $(git log intarweb-dev --oneline -1)"
86+
echo " intarweb-dev commits ahead of upstream/main:"
87+
git log --oneline upstream/main..intarweb-dev | sed 's/^/ /' || true

0 commit comments

Comments
 (0)