Skip to content

Sync Vim PR Changes #90

Sync Vim PR Changes

Sync Vim PR Changes #90

Workflow file for this run

name: Sync Vim PR Changes
on:
schedule:
# Every 8 hours, same as sync-cached (runs in parallel)
- cron: '0 1,9,17 * * *'
workflow_dispatch:
permissions:
contents: read
issues: write
jobs:
check-pr-drift:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check if PR #12679 has changed
id: check
run: |
# Check if PR is still open
PR_STATE=$(gh pr view 12679 --repo anomalyco/opencode --json state --jq .state 2>/dev/null || echo "UNKNOWN")
echo "pr_state=$PR_STATE" >> $GITHUB_OUTPUT
if [ "$PR_STATE" = "MERGED" ]; then
echo "PR #12679 has been merged -- vim patch may no longer be needed"
echo "merged=true" >> $GITHUB_OUTPUT
exit 0
fi
if [ "$PR_STATE" = "CLOSED" ]; then
echo "PR #12679 was closed without merging"
echo "closed=true" >> $GITHUB_OUTPUT
exit 0
fi
# Fetch current PR diff
gh pr diff 12679 --repo anomalyco/opencode > /tmp/raw-vim.patch 2>/dev/null || {
echo "Failed to fetch PR diff"
echo "fetch_failed=true" >> $GITHUB_OUTPUT
exit 0
}
# Compare with committed patch (by hash)
CURRENT_HASH=$(sha256sum /tmp/raw-vim.patch | cut -d' ' -f1)
COMMITTED_HASH=$(sha256sum patches/vim.patch | cut -d' ' -f1)
echo "Current PR diff hash: $CURRENT_HASH"
echo "Committed patch hash: $COMMITTED_HASH"
if [ "$CURRENT_HASH" != "$COMMITTED_HASH" ]; then
echo "PR diff has changed since vim.patch was generated"
echo "drifted=true" >> $GITHUB_OUTPUT
else
echo "No changes detected"
echo "drifted=false" >> $GITHUB_OUTPUT
fi
env:
GH_TOKEN: ${{ github.token }}
- name: Create drift issue
if: steps.check.outputs.drifted == 'true'
uses: actions/github-script@v7
with:
script: |
const title = 'Patch drift: vim.patch no longer matches PR #12679 - review needed';
const body = `
## Patch Drift Detected: vim.patch vs PR #12679
The upstream [PR #12679](https://github.com/anomalyco/opencode/pull/12679) has been updated.
The committed \`patches/vim.patch\` no longer matches the current PR diff.
**This is a review signal, not a build failure.** The build continues to use the
committed \`patches/vim.patch\` as-is. Whether that patch still applies cleanly and
whether publication is blocked is determined by the build/release workflow, not this check.
### Action Required
1. Review what changed in the PR: \`gh pr diff 12679 --repo anomalyco/opencode\`
2. Decide whether to adopt the updated diff:
- If yes, regenerate the patch:
\`\`\`bash
gh pr diff 12679 --repo anomalyco/opencode > patches/vim.patch
git add patches/vim.patch
git commit -m "chore: update vim.patch from PR #12679"
git push
\`\`\`
- If no, close this issue with a note explaining why
3. Verify the updated patch still stacks cleanly with the caching patch
4. Close this issue when done
**PR**: https://github.com/anomalyco/opencode/pull/12679
`;
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: 'patch-drift'
});
const existingIssue = issues.data.find(i => i.title.includes('PR #12679'));
if (existingIssue) {
console.log(`Issue already exists: #${existingIssue.number}`);
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: existingIssue.number,
body: `Drift still present (${new Date().toISOString().split('T')[0]}): PR #12679 diff continues to differ from committed \`patches/vim.patch\`. Build is unaffected until manually reviewed and updated.`
});
} else {
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: title,
body: body,
labels: ['patch-drift', 'review-needed']
});
console.log('Created drift issue');
}
- name: Report status
run: |
echo "PR #12679 state: ${{ steps.check.outputs.pr_state }}"
echo "Drifted: ${{ steps.check.outputs.drifted }}"