From baae470d78370945dac2331d721b2dd4de1d29f8 Mon Sep 17 00:00:00 2001 From: liuji Date: Sat, 10 Oct 2026 16:58:51 +0800 Subject: [PATCH] Simplify AgentStage configuration --- .gitea/deployment-secrets.example.env | 10 ---------- .gitea/deployment-vars.example.env | 9 --------- REAMME.md | 14 +++++++++++--- schedule.conf | 2 +- sync.py | 2 +- 5 files changed, 13 insertions(+), 24 deletions(-) delete mode 100755 .gitea/deployment-secrets.example.env delete mode 100755 .gitea/deployment-vars.example.env diff --git a/.gitea/deployment-secrets.example.env b/.gitea/deployment-secrets.example.env deleted file mode 100755 index ccd8447..0000000 --- a/.gitea/deployment-secrets.example.env +++ /dev/null @@ -1,10 +0,0 @@ -# Gitea repository Secrets template. -# Create the two repository Secrets with these exact names under -# Repository Settings -> Actions -> Secrets, then enter values only in Gitea. -# This committed template intentionally contains no secret values. - -# Git credential/token used by the publisher for the ttshop repository. -GIT_CREDENTIAL_SECRET= - -# HTTPS endpoint receiving exactly one notification for a failed run. -SYNC_FAILURE_WEBHOOK_URL= diff --git a/.gitea/deployment-vars.example.env b/.gitea/deployment-vars.example.env deleted file mode 100755 index 584ea31..0000000 --- a/.gitea/deployment-vars.example.env +++ /dev/null @@ -1,9 +0,0 @@ -# Gitea repository Variables template (non-sensitive values only). -# Create these under Repository Settings -> Actions -> Variables. -# Do not place credentials or a webhook URL in this file. - -# Public HTTPS origin of the Gitea instance, without repository path/query/fragment. -GITEA_BASE_URL=https://gitea.example.invalid - -# One URL path segment identifying the repository owner or organization. -GITEA_OWNER=replace-with-gitea-owner diff --git a/REAMME.md b/REAMME.md index e7d84ca..4a103ed 100755 --- a/REAMME.md +++ b/REAMME.md @@ -8,13 +8,19 @@ TTSHOP 从公开的 Google Sheets 工作簿读取销售数据,生成合并后 ## 数据同步 -数据源是公开的 Google Sheets 工作簿,固定 ID 为: +数据源是公开的 Google Sheets 工作簿。`sync.py` 默认使用以下工作簿 ID: ```text 1DPbdVsX3SG_kgDXs2j34mDAgplRSfcAWKKG9yqalFmw ``` -`sync.py` 的处理流程如下: +运行时可通过 `WORKBOOK_ID` 环境变量覆盖默认值,例如: + +```sh +WORKBOOK_ID=your-workbook-id ./update.sh +``` + +未设置 `WORKBOOK_ID` 时,脚本继续使用上述默认值。`sync.py` 的处理流程如下: 1. 读取 XLSX 导出文件,获取工作表顺序。 2. 使用 Google Visualization API(gviz)读取各工作表中的显示值。 @@ -52,7 +58,9 @@ TTSHOP 从公开的 Google Sheets 工作簿读取销售数据,生成合并后 AgentStage 自动执行仓库根目录的 `update.sh`,不使用 Gitea Actions workflow。 -`schedule.conf` 当前值为 `8`,表示每 8 小时自动运行一次。`update.sh` 会执行 `sync.py`;同步失败时返回非零状态。 +`schedule.conf` 为单独一行 `3`,表示每 3 小时自动运行一次。`update.sh` 会执行 `sync.py`。 + +当前没有独立持久化的更新日志;AgentStage 任务日志以及脚本的 stdout/stderr 是运行日志。同步失败时脚本返回非零退出状态。只有在 AgentStage 运行环境中配置并注入 `SYNC_FAILURE_WEBHOOK_URL` 时,脚本才会发送一次失败 Webhook;未配置时不会发送主动通知。Webhook URL 必须由 AgentStage 运行环境注入,不会因为仓库中的模板文件而自动生效。 ## 本地手动运行 diff --git a/schedule.conf b/schedule.conf index 45a4fb7..00750ed 100755 --- a/schedule.conf +++ b/schedule.conf @@ -1 +1 @@ -8 +3 diff --git a/sync.py b/sync.py index f6f9b40..a498bf2 100755 --- a/sync.py +++ b/sync.py @@ -19,7 +19,7 @@ import requests ROOT = Path(__file__).resolve().parent -WORKBOOK_ID = "1DPbdVsX3SG_kgDXs2j34mDAgplRSfcAWKKG9yqalFmw" +WORKBOOK_ID = os.getenv("WORKBOOK_ID", "1DPbdVsX3SG_kgDXs2j34mDAgplRSfcAWKKG9yqalFmw") PUBLISH_PATH = Path("data/merged.html") GVIZ_PREFIX = "google.visualization.Query.setResponse("