Skip to content

Commit 95ea251

Browse files
John Doeclaude
andcommitted
ci: add daily upstream sync from garrytan/gstack
Runs daily at 08:17 UTC + manual trigger. Fast-forwards if clean, creates a PR with conflict markers if merge conflicts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent cf0986d commit 95ea251

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Sync upstream
2+
3+
on:
4+
schedule:
5+
- cron: '17 8 * * *' # Daily at 08:17 UTC
6+
workflow_dispatch: # Manual trigger
7+
8+
jobs:
9+
sync:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Sync upstream
19+
run: |
20+
git remote add upstream https://github.com/garrytan/gstack.git
21+
git fetch upstream main
22+
23+
BEHIND=$(git rev-list --count HEAD..upstream/main)
24+
if [ "$BEHIND" -eq 0 ]; then
25+
echo "Already up to date with upstream."
26+
exit 0
27+
fi
28+
29+
echo "Behind upstream by $BEHIND commits. Merging..."
30+
git config user.name "github-actions[bot]"
31+
git config user.email "github-actions[bot]@users.noreply.github.com"
32+
33+
if git merge upstream/main --no-edit; then
34+
git push origin main
35+
echo "Synced $BEHIND commits from upstream."
36+
else
37+
echo "Merge conflict detected. Creating PR instead."
38+
git merge --abort
39+
40+
BRANCH="sync-upstream-$(date +%Y%m%d)"
41+
git checkout -b "$BRANCH"
42+
git merge upstream/main --no-edit || true
43+
git add -A
44+
git commit -m "chore: sync upstream (conflicts need manual resolution)" --no-verify || true
45+
git push -u origin "$BRANCH"
46+
47+
gh pr create \
48+
--title "chore: sync upstream (merge conflicts)" \
49+
--body "Automatic upstream sync found merge conflicts. Please resolve manually." \
50+
--base main \
51+
--head "$BRANCH"
52+
fi
53+
env:
54+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)