mirror of
https://github.com/shuaiplus/nodewarden.git
synced 2026-06-20 13:00:39 +00:00
feat: add workflow to import KV ID from NodeWarden2 and update README for deployment instructions
This commit is contained in:
@@ -0,0 +1,59 @@
|
|||||||
|
name: Import KV ID from NodeWarden2
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
patch:
|
||||||
|
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: Import KV namespace id from NodeWarden2
|
||||||
|
env:
|
||||||
|
REPO_OWNER: ${{ github.repository_owner }}
|
||||||
|
run: |
|
||||||
|
python - <<'PY'
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
from pathlib import Path
|
||||||
|
from urllib.request import urlopen
|
||||||
|
|
||||||
|
owner = os.environ["REPO_OWNER"]
|
||||||
|
source_url = f"https://raw.githubusercontent.com/{owner}/nodewarden2/main/wrangler.toml"
|
||||||
|
with urlopen(source_url) as response:
|
||||||
|
source_text = response.read().decode("utf-8")
|
||||||
|
|
||||||
|
source_match = re.search(r'id\s*=\s*"([^"]+)"', source_text)
|
||||||
|
if not source_match:
|
||||||
|
raise SystemExit('No `id = "..."` found in nodewarden2/wrangler.toml')
|
||||||
|
|
||||||
|
kv_id = source_match.group(1)
|
||||||
|
|
||||||
|
target_path = Path("wrangler.toml")
|
||||||
|
target_text = target_path.read_text(encoding="utf-8")
|
||||||
|
target_text, count = re.subn(r'id\s*=\s*"[^"]+"', f'id = "{kv_id}"', target_text, count=1)
|
||||||
|
|
||||||
|
if count == 0:
|
||||||
|
raise SystemExit('No `id = "..."` found in current wrangler.toml')
|
||||||
|
|
||||||
|
target_path.write_text(target_text, encoding="utf-8")
|
||||||
|
PY
|
||||||
|
|
||||||
|
- name: Commit imported KV id
|
||||||
|
run: |
|
||||||
|
git add wrangler.toml
|
||||||
|
git diff --cached --quiet && exit 0
|
||||||
|
git commit -m "chore: import kv id from nodewarden2"
|
||||||
|
git push origin main
|
||||||
@@ -54,7 +54,6 @@ English:[`README_EN.md`](./README_EN.md)
|
|||||||
|
|
||||||
### 一键部署
|
### 一键部署
|
||||||
|
|
||||||
**部署步骤:**
|
|
||||||
|
|
||||||
> **若你只是想快速体验,直接点击第 2 步的一键部署按钮即可;以下步骤主要为了后续长期更新。**
|
> **若你只是想快速体验,直接点击第 2 步的一键部署按钮即可;以下步骤主要为了后续长期更新。**
|
||||||
|
|
||||||
@@ -64,8 +63,8 @@ English:[`README_EN.md`](./README_EN.md)
|
|||||||
|
|
||||||
[](https://deploy.workers.cloudflare.com/?url=https://github.com/shuaiplus/NodeWarden)
|
[](https://deploy.workers.cloudflare.com/?url=https://github.com/shuaiplus/NodeWarden)
|
||||||
|
|
||||||
3. 部署完成后,在同一页面打开 Workers 设置,将 **Git 存储库** 断开连接。
|
3. 部署完成后,在同一页面打开 Workers 设置,将 `Git 存储库` 断开连接。
|
||||||
4. 在同一位置重新连接到第 1 步 Fork 的仓库,并在页面底部将 **名称** 改回 **NodeWarden**。
|
4. 在同一位置重新连接到第 1 步 Fork 的仓库,并在页面底部将`名称` 改回 **NodeWarden**。
|
||||||
5. GitHub 仓库 **NodeWarden2** 可以删除。
|
5. GitHub 仓库 **NodeWarden2** 可以删除。
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
@@ -76,20 +75,22 @@ English:[`README_EN.md`](./README_EN.md)
|
|||||||
>- **R2**:需绑定银行卡;**单个附件 / Send 文件上限 100 MB**(代码限制,可自行修改);**总量 10 GB 免费**
|
>- **R2**:需绑定银行卡;**单个附件 / Send 文件上限 100 MB**(代码限制,可自行修改);**总量 10 GB 免费**
|
||||||
>- **KV**:无需绑卡;**单个附件 / Send 文件上限 25 MiB**(Cloudflare 限制,不可修改);**总量 1 GB 免费**
|
>- **KV**:无需绑卡;**单个附件 / Send 文件上限 25 MiB**(Cloudflare 限制,不可修改);**总量 1 GB 免费**
|
||||||
>
|
>
|
||||||
>1. 先 Fork 本仓库,并命名为 **NodeWarden**。
|
>1. 先 Fork 本仓库,并命名为 **NodeWarden**(默认自动填写)
|
||||||
>2. 打开 GitHub 仓库,进入 `Actions` 页面,运行 **Switch to KV mode**(自动将 [wrangler.toml](./wrangler.toml) 切换为 KV 配置。)
|
>2. 进入新仓库,进入 `Actions` 页面,点击 `I understand my workflows, go ahead and enable them`,点击 `Switch to KV mode`,点击`Run Workflow`
|
||||||
>3. **在你自己的仓库中**点击下面的按钮,在打开的页面中将项目名称改为 **NodeWarden2**,并将 **JWT_SECRET** 设置为 32 位随机字符串。
|
>3. 成功后**在你自己的仓库中**点击下面的按钮,在打开的页面中将项目名称改为 **NodeWarden2**,并将 **JWT_SECRET** 设置为 32 位随机字符串。
|
||||||
>
|
>
|
||||||
> [](https://deploy.workers.cloudflare.com/?url=https://github.com/shuaiplus/NodeWarden)
|
> [](https://deploy.workers.cloudflare.com/?url=https://github.com/shuaiplus/NodeWarden)
|
||||||
>
|
>
|
||||||
>4. 部署完成后,在同一页面打开 Workers 设置,将 **Git 存储库** 断开连接。
|
>4. 在同一页面打开 Workers 设置,将 `Git 存储库` 断开连接。
|
||||||
>5. 在同一位置重新连接到第 1 步 Fork 的仓库,并在页面底部将 **名称** 改回 **NodeWarden**。
|
>5. 返回Github进入Fork后的仓库(NodeWarden),进入 `Actions` 页面,运行`Import KV ID from NodeWarden2`
|
||||||
>6. GitHub 仓库 **NodeWarden2** 可以删除。
|
>6. 返回cloudflare,`Git 存储库`连接到Fork后的仓库(NodeWarden),并在页面底部将`名称`改回 **NodeWarden**。
|
||||||
|
>7. GitHub 仓库 **NodeWarden2** 可以删除了。
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
> [!TIP]
|
> [!TIP]
|
||||||
> 同步上游(更新仓库):
|
> 同步方法(更新仓库):
|
||||||
>- 手动:打开你 Fork 的 GitHub 仓库,看到顶部同步提示后,点击 `Sync fork`。
|
>- 手动:打开你 Fork 的 GitHub 仓库,看到顶部同步提示后,点击 `Sync fork`。(不要点Contribute)
|
||||||
>- 自动:进入你的 Fork 仓库 -> `Actions`,点击 `I understand my workflows, go ahead and enable them`,启用后,`Sync upstream` 会在每天凌晨 3 点自动同步上游 `main`,并保留你当前的 [wrangler.toml](./wrangler.toml) 配置不被覆盖。
|
>- 自动:进入你的 Fork 仓库 -> `Actions`,点击 `I understand my workflows, go ahead and enable them`,启用后,`Sync upstream` 会在每天凌晨 3 点自动同步上游 `main`,并保留你当前的 [wrangler.toml](./wrangler.toml) 配置不被覆盖。
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+7
-8
@@ -55,8 +55,6 @@
|
|||||||
|
|
||||||
### One-click deploy
|
### One-click deploy
|
||||||
|
|
||||||
**Deploy steps:**
|
|
||||||
|
|
||||||
> **If you only want a quick trial, simply click the one-click deploy button in step 2. The remaining steps are mainly for long-term maintenance.**
|
> **If you only want a quick trial, simply click the one-click deploy button in step 2. The remaining steps are mainly for long-term maintenance.**
|
||||||
|
|
||||||
1. Fork this repository and name it **NodeWarden**.
|
1. Fork this repository and name it **NodeWarden**.
|
||||||
@@ -76,19 +74,20 @@
|
|||||||
>- **KV**: no card required; **single attachment / Send file limit is 25 MiB** (Cloudflare limit, not editable); **1 GB free storage**
|
>- **KV**: no card required; **single attachment / Send file limit is 25 MiB** (Cloudflare limit, not editable); **1 GB free storage**
|
||||||
>
|
>
|
||||||
>1. Fork this repository and name it **NodeWarden**.
|
>1. Fork this repository and name it **NodeWarden**.
|
||||||
>2. Open your GitHub repository, go to the `Actions` page, and run **Switch to KV mode** (this automatically switches [wrangler.toml](./wrangler.toml) to the KV configuration).
|
>2. Open your new repository, go to `Actions`, click `I understand my workflows, go ahead and enable them`, then run `Switch to KV mode`.
|
||||||
>3. **In your own repository**, click the button below. On the page that opens, rename the project to **NodeWarden2** and set **JWT_SECRET** to a random 32-character string.
|
>3. After that, **in your own repository**, click the button below. On the page that opens, rename the project to **NodeWarden2** and set **JWT_SECRET** to a random 32-character string.
|
||||||
>
|
>
|
||||||
> [](https://deploy.workers.cloudflare.com/?url=https://github.com/shuaiplus/NodeWarden)
|
> [](https://deploy.workers.cloudflare.com/?url=https://github.com/shuaiplus/NodeWarden)
|
||||||
>
|
>
|
||||||
>4. After deployment, open the Worker settings on the same page and disconnect the **Git repository**.
|
>4. On the same page, open the Worker settings and disconnect the `Git repository`.
|
||||||
>5. Reconnect the **Git repository** to the fork from step 1, then change the **Name** field at the bottom to **NodeWarden**.
|
>5. Go back to your forked repository (**NodeWarden**) on GitHub, open `Actions`, and run `Import KV ID from NodeWarden2`.
|
||||||
>6. The GitHub repository **NodeWarden2** can be deleted.
|
>6. Return to Cloudflare, reconnect the `Git repository` to your forked repository (**NodeWarden**), and change the `Name` field at the bottom back to **NodeWarden**.
|
||||||
|
>7. The GitHub repository **NodeWarden2** can then be deleted.
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
> [!TIP]
|
> [!TIP]
|
||||||
> Sync upstream (keep your fork updated):
|
> Sync upstream (keep your fork updated):
|
||||||
>- Manual: open your fork on GitHub and click `Sync fork` when prompted.
|
>- Manual: open your fork on GitHub and click `Sync fork` when prompted. Do not click `Contribute`.
|
||||||
>- Automatic: in your fork, go to `Actions`, click `I understand my workflows, go ahead and enable them`. Once enabled, `Sync upstream` will automatically sync the upstream `main` branch every day at 3 AM and keep your current [wrangler.toml](./wrangler.toml) configuration unchanged.
|
>- Automatic: in your fork, go to `Actions`, click `I understand my workflows, go ahead and enable them`. Once enabled, `Sync upstream` will automatically sync the upstream `main` branch every day at 3 AM and keep your current [wrangler.toml](./wrangler.toml) configuration unchanged.
|
||||||
|
|
||||||
### CLI deploy
|
### CLI deploy
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
type Locale = 'en' | 'zh-CN';
|
type Locale = 'en' | 'zh-CN';
|
||||||
|
|
||||||
const LOCALE_STORAGE_KEY = 'nodewarden.locale';
|
const LOCALE_STORAGE_KEY = 'nodewarden.locale';
|
||||||
|
|
||||||
@@ -153,7 +153,7 @@ const messages: Record<Locale, Record<string, string>> = {
|
|||||||
txt_identity: "Identity",
|
txt_identity: "Identity",
|
||||||
txt_identity_details: "Identity Details",
|
txt_identity_details: "Identity Details",
|
||||||
txt_ie_browser: "IE Browser",
|
txt_ie_browser: "IE Browser",
|
||||||
txt_invite_code_optional: "Invite Code (Optional)",
|
txt_invite_code_optional: "Invite Code (Not required for the first account; required for all others)",
|
||||||
txt_invite_created: "Invite created",
|
txt_invite_created: "Invite created",
|
||||||
txt_invite_revoked: "Invite revoked",
|
txt_invite_revoked: "Invite revoked",
|
||||||
txt_invite_validity_hours: "Invite validity (hours)",
|
txt_invite_validity_hours: "Invite validity (hours)",
|
||||||
@@ -625,7 +625,7 @@ const zhCNOverrides: Record<string, string> = {
|
|||||||
txt_folder_created: '文件夹已创建',
|
txt_folder_created: '文件夹已创建',
|
||||||
txt_folder_name_is_required: '文件夹名称不能为空',
|
txt_folder_name_is_required: '文件夹名称不能为空',
|
||||||
txt_ie_browser: 'IE 浏览器',
|
txt_ie_browser: 'IE 浏览器',
|
||||||
txt_invite_code_optional: '邀请码(可选)',
|
txt_invite_code_optional: '邀请码(首位注册者无需填写,其他人必填)',
|
||||||
txt_invite_created: '邀请码已创建',
|
txt_invite_created: '邀请码已创建',
|
||||||
txt_invite_revoked: '邀请码已撤销',
|
txt_invite_revoked: '邀请码已撤销',
|
||||||
txt_ios: 'iOS',
|
txt_ios: 'iOS',
|
||||||
@@ -909,3 +909,4 @@ export function setLocale(next: Locale): void {
|
|||||||
// ignore storage errors
|
// ignore storage errors
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user