mirror of
https://github.com/shuaiplus/nodewarden.git
synced 2026-06-20 13:00:39 +00:00
feat: update sync workflow and README for KV storage support
This commit is contained in:
@@ -4,6 +4,9 @@ on:
|
||||
schedule:
|
||||
- cron: "0 3 * * *"
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
@@ -17,12 +20,45 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- run: |
|
||||
git remote add upstream https://github.com/shuaiplus/nodewarden.git || true
|
||||
- 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
|
||||
|
||||
# 强制让当前分支完全等于 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
|
||||
|
||||
Reference in New Issue
Block a user