name: Sync upstream on: schedule: - cron: "0 3 * * *" workflow_dispatch: push: branches: - main permissions: contents: write jobs: sync: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Configure git run: | git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - name: Sync main from upstream run: | git remote add upstream https://github.com/shuaiplus/NodeWarden.git || true git fetch upstream git checkout main git reset --hard upstream/main git push origin main --force - name: Rebuild kv from main run: | git fetch origin main kv || true git checkout -B kv origin/main python - <<'PY' from pathlib import Path path = Path("wrangler.toml") text = path.read_text(encoding="utf-8") old = """[[r2_buckets]] binding = "ATTACHMENTS" bucket_name = "nodewarden-attachments" """ new = """[[kv_namespaces]] binding = "ATTACHMENTS_KV" id = "REPLACE_WITH_KV_NAMESPACE_ID" """ if old not in text: raise SystemExit("Expected R2 block not found in wrangler.toml") path.write_text(text.replace(old, new, 1), encoding="utf-8") PY git add wrangler.toml git commit -m "chore(kv): sync from main" || echo "No changes" git push origin kv --force