Files
opencode/.github/workflows/upstream-sync.yml
T
Artur Do Lago 4e08a34ff1 feat(sync): complete Phase 5 upstream sync infrastructure
- Add .github/workflows/upstream-sync.yml for weekly upstream checks
  - Scheduled weekly on Mondays
  - Manual trigger with optional PR creation
  - Conflict detection in workflow summary
- Add scripts/validate-sync.sh for post-merge validation
  - Checks critical persona files exist
  - Validates agent-core naming preserved
  - Verifies persona themes registered
  - TypeScript compilation check
- Update ROADMAP.md marking Phase 5 as complete
- Remove Electron/browser extension from backlog (TUI is our desktop app)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:34:57 +01:00

150 lines
5.1 KiB
YAML

name: upstream-sync
on:
schedule:
# Check weekly on Mondays at 9am UTC
- cron: '0 9 * * 1'
workflow_dispatch:
inputs:
create_pr:
description: 'Create PR if behind upstream'
type: boolean
default: false
jobs:
check-upstream:
runs-on: ubuntu-latest
outputs:
behind: ${{ steps.check.outputs.behind }}
ahead: ${{ steps.check.outputs.ahead }}
merge_base: ${{ steps.check.outputs.merge_base }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Add upstream remote
run: |
git remote add upstream https://github.com/sst/opencode.git || true
git fetch upstream --tags
- name: Check divergence
id: check
run: |
MERGE_BASE=$(git merge-base HEAD upstream/dev)
read AHEAD BEHIND <<< "$(git rev-list --left-right --count HEAD...upstream/dev)"
echo "merge_base=${MERGE_BASE:0:10}" >> $GITHUB_OUTPUT
echo "ahead=$AHEAD" >> $GITHUB_OUTPUT
echo "behind=$BEHIND" >> $GITHUB_OUTPUT
echo "## Upstream Sync Status" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Metric | Value |" >> $GITHUB_STEP_SUMMARY
echo "|--------|-------|" >> $GITHUB_STEP_SUMMARY
echo "| Merge base | \`${MERGE_BASE:0:10}\` |" >> $GITHUB_STEP_SUMMARY
echo "| Commits ahead | $AHEAD |" >> $GITHUB_STEP_SUMMARY
echo "| Commits behind | $BEHIND |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ "$BEHIND" -gt 0 ]; then
echo "### Upstream commits to merge" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
git log --oneline "$MERGE_BASE..upstream/dev" | head -20 >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
fi
- name: Check for conflicts
if: steps.check.outputs.behind != '0'
run: |
echo "### Potential Conflicts" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
MERGE_BASE=$(git merge-base HEAD upstream/dev)
UPSTREAM_CHANGED=$(git diff --name-only "$MERGE_BASE..upstream/dev")
OUR_CHANGED=$(git diff --name-only "$MERGE_BASE..HEAD")
CONFLICTS=""
for file in $UPSTREAM_CHANGED; do
if echo "$OUR_CHANGED" | grep -q "^$file$"; then
CONFLICTS="$CONFLICTS\n- \`$file\`"
fi
done
if [ -n "$CONFLICTS" ]; then
echo "Files modified in both branches:" >> $GITHUB_STEP_SUMMARY
echo -e "$CONFLICTS" >> $GITHUB_STEP_SUMMARY
else
echo "No obvious conflicts detected." >> $GITHUB_STEP_SUMMARY
fi
notify:
needs: check-upstream
runs-on: ubuntu-latest
if: needs.check-upstream.outputs.behind != '0'
steps:
- name: Summary
run: |
echo "Agent-core is ${{ needs.check-upstream.outputs.behind }} commits behind upstream."
echo "Run ./scripts/sync-upstream.sh --preview to see details."
create-sync-pr:
needs: check-upstream
runs-on: ubuntu-latest
if: github.event.inputs.create_pr == 'true' && needs.check-upstream.outputs.behind != '0'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Git
run: |
git config user.email "bot@agent-core.dev"
git config user.name "agent-core-bot"
- name: Add upstream and create sync branch
run: |
git remote add upstream https://github.com/sst/opencode.git || true
git fetch upstream
BRANCH="sync/upstream-$(date +%Y%m%d)"
git checkout -b "$BRANCH"
# Attempt merge
if git merge upstream/dev --no-edit -m "Sync upstream OpenCode $(git log -1 --format=%h upstream/dev)"; then
git push origin "$BRANCH"
echo "SYNC_BRANCH=$BRANCH" >> $GITHUB_ENV
echo "MERGE_SUCCESS=true" >> $GITHUB_ENV
else
echo "MERGE_SUCCESS=false" >> $GITHUB_ENV
git merge --abort
fi
- name: Create PR
if: env.MERGE_SUCCESS == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr create \
--title "Sync upstream OpenCode (${{ needs.check-upstream.outputs.behind }} commits)" \
--body "## Upstream Sync
Merging ${{ needs.check-upstream.outputs.behind }} commits from upstream OpenCode.
**Merge base:** \`${{ needs.check-upstream.outputs.merge_base }}\`
### Checklist
- [ ] Review changes for conflicts with our customizations
- [ ] Run \`bun turbo typecheck\`
- [ ] Run \`bun turbo test\`
- [ ] Test with all personas (zee, stanley, johny)
---
*Auto-generated by upstream-sync workflow*" \
--base dev \
--head "${{ env.SYNC_BRANCH }}"