Skip to content

Commit 9aab6d9

Browse files
0xClandestineclaude
andcommitted
ci: daily auto-sync from upstream rtk-ai/rtk
Merges upstream/master into our master once a day (06:00 UTC). On clean merge, pushes automatically. On conflict, opens a GitHub issue labelled upstream-sync so it can be resolved manually. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent b0c0a38 commit 9aab6d9

1 file changed

Lines changed: 78 additions & 0 deletions

File tree

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Sync upstream
2+
3+
on:
4+
schedule:
5+
- cron: '0 6 * * *' # daily at 06:00 UTC
6+
workflow_dispatch: # allow manual trigger
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
sync:
13+
name: Merge upstream/master
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
ref: master
19+
fetch-depth: 0
20+
token: ${{ secrets.GITHUB_TOKEN }}
21+
22+
- name: Configure git
23+
run: |
24+
git config user.name "github-actions[bot]"
25+
git config user.email "github-actions[bot]@users.noreply.github.com"
26+
27+
- name: Add upstream remote
28+
run: git remote add upstream https://github.com/rtk-ai/rtk.git
29+
30+
- name: Fetch upstream
31+
run: git fetch upstream master
32+
33+
- name: Merge upstream/master
34+
id: merge
35+
run: |
36+
if git merge --no-edit upstream/master; then
37+
echo "merged=true" >> "$GITHUB_OUTPUT"
38+
else
39+
echo "merged=false" >> "$GITHUB_OUTPUT"
40+
git merge --abort
41+
fi
42+
43+
- name: Push if merged cleanly
44+
if: steps.merge.outputs.merged == 'true'
45+
run: git push origin master
46+
47+
- name: Open issue on conflict
48+
if: steps.merge.outputs.merged == 'false'
49+
uses: actions/github-script@v7
50+
with:
51+
script: |
52+
const title = 'Upstream sync conflict — manual merge required';
53+
const { data: issues } = await github.rest.issues.listForRepo({
54+
owner: context.repo.owner,
55+
repo: context.repo.repo,
56+
state: 'open',
57+
labels: 'upstream-sync',
58+
});
59+
if (issues.some(i => i.title === title)) return; // already open
60+
await github.rest.issues.create({
61+
owner: context.repo.owner,
62+
repo: context.repo.repo,
63+
title,
64+
labels: ['upstream-sync'],
65+
body: [
66+
'`sync-upstream` workflow failed to auto-merge.',
67+
'',
68+
'Run locally to resolve:',
69+
'```',
70+
'git fetch upstream',
71+
'git merge upstream/master',
72+
'# fix conflicts',
73+
'git push',
74+
'```',
75+
'',
76+
`Triggered by run: ${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`,
77+
].join('\n'),
78+
});

0 commit comments

Comments
 (0)