后台一键更新改为从 git.dan9.si 同步 #1

Merged
saki merged 4 commits from duet/update-from-dan9 into main 2026-11-28 22:56:56 +00:00
Member

之前: /admin 的「更新」依赖 GitHub 上的 Aelios-project/Aelios 上游。这个上游已经不在了(404),所以按钮查不到新版本,也同步不了。另外它要求部署仓库是 GitHub Fork,独立副本用不了。

之后: 「更新」先通过 Forgejo API 查 git.dan9.si 的 main,再到用户自己的 GitHub 仓库里触发同步工作流:拉取、合并、推到 main,然后 Cloudflare Workers Builds 照常部署。Fork 和独立副本都能用。上游地址只是默认值,可以用 AELIOS_UPSTREAM_URL 改。

改了什么

  • 同步工作流 .github/workflows/sync-from-dan9.yml
    • 支持手动触发(workflow_dispatch)。每周的定时任务默认不跑,仓库变量 AELIOS_AUTO_SYNC=true 时才运行。
    • 能快进就快进,不能就生成合并提交。有冲突时中止合并,什么都不推,在运行摘要里列出冲突文件和手动处理的命令。
    • 上游默认 https://git.dan9.si/Aelios-project/Aelios.git,可以用仓库变量 AELIOS_UPSTREAM_URL 改。
    • 如果上游改动了 .github/workflows/,需要仓库 secret AELIOS_SYNC_TOKEN(带 workflow 权限的 PAT)。没配时运行会失败,并说明该怎么配。
  • 后台逻辑
    • 涉及文件:src/api/admin/deploymentUpdate.ts、updateGithubApp.ts、updateGithub.ts。
    • 用 Forgejo 的 /api/v1/repos/<owner>/<repo>/branches/main 取上游最新提交,再和用户仓库 main 比较。比较走 GitHub compare:ahead_by 判断有没有新版本,返回 404 说明用户仓库还没有这个提交。
    • 按钮调用 workflow dispatch,然后跟踪这次运行,再跟踪 Cloudflare 构建,直到新提交上线。
    • 更新 App 的 manifest 加了 Actions: Read and write。已经连接、缺这项权限的老 App,签发令牌时会退回旧权限,界面上用一句话告诉用户去哪里补这项权限。
    • 删掉了「必须是 Fork」的检查。
    • 仓库里还没有工作流时,界面显示三行手动更新命令。
    • Forgejo 连不上时显示「暂时连不上上游」,不会误报失败。
  • 迁移 migrations/0037_admin_deployment_sync.sql:保存同步运行的状态。
  • 界面:ui/shell.ts 和 ui/scripts/deploymentUpdate.ts,加了新的提示文案和缺工作流时的命令块。
  • 文档
    • README.md、README.zh-CN.md、docs/setup-with-ai.md 改为从 git.dan9.si 搬到自己的 GitHub 仓库(GitHub 导入或 clone 后 push),去掉 Deploy to Cloudflare 按钮,新增「更新到最新版」一节,内容包括后台更新、手动更新和老部署怎么迁。
    • SECRETS.md 补了 AELIOS_UPSTREAM_URL、AELIOS_SYNC_TOKEN、AELIOS_AUTO_SYNC 的说明。
  • 测试 tests/admin-deployment-update.test.ts 覆盖五种情况:有新版本、已是最新、缺工作流、权限不足、Forgejo 失败。tests/settings-coverage.test.ts 同步更新。

代码里没有写进任何人的私人地址或数据,git.dan9.si 只作为可以改的默认值出现。

怎么测的

  • npm run typecheck 通过。
  • npm test:703 个通过,0 个失败。
  • npm run verify 通过,包括在本地 D1 上依次应用全部迁移(含 0037)。
  • npm run lint:0 个 error,48 个 warning,和 main 原有的一致。
  • 在 bash 里模拟了工作流逻辑的四种情况:已是最新、快进、带工作流改动的合并(没有 token 时正确停下)、冲突(中止且不推送)。
  • 说明:沙盒的代理拦截了 git.dan9.si 的 clone,所以测试是在 main 68025f7 的完整副本上跑的,内容和 main 一致。工作流本身没有在真实的 GitHub Actions 上跑过,合并后建议先在自己的仓库手动触发一次确认。

老用户迁移步骤

  1. 在自己仓库的本地克隆里跑一次下面三行,把同步工作流和新版更新按钮一起拉进来:
    git remote add dan9 https://git.dan9.si/Aelios-project/Aelios.git
    git pull --no-rebase dan9 main
    git push
    
  2. 如果仓库的 Actions 页显示工作流被关闭(新 Fork 默认关闭),先启用。
  3. 等 Cloudflare 部署完,到 GitHub Settings → Developer settings → GitHub Apps → Aelios 更新 App → Permissions,把 Actions 设为 Read and write 并保存,再到安装页批准新权限。用 AELIOS_UPDATE_GITHUB_TOKEN 的,给令牌加同样的权限。
  4. 可选:添加仓库 secret AELIOS_SYNC_TOKEN。上游改动工作流文件时需要它。
  5. 可选:设置仓库变量 AELIOS_AUTO_SYNC=true,每周自动同步。要换上游的,把 AELIOS_UPSTREAM_URL 同时设成仓库变量和 Worker 变量。

之后在 /admin 点「更新」就行。Cloudflare 里的记忆和设置不受影响。

没动的

两份 README 里指向 GitHub 上 Aelios-resident 的链接,以及 SECURITY.md 里的 issue 链接,GitHub 上也已经失效,但不在这次的范围内,没有改。

🤖 Generated with Claude Code

**之前:** /admin 的「更新」依赖 GitHub 上的 `Aelios-project/Aelios` 上游。这个上游已经不在了(404),所以按钮查不到新版本,也同步不了。另外它要求部署仓库是 GitHub Fork,独立副本用不了。 **之后:** 「更新」先通过 Forgejo API 查 git.dan9.si 的 `main`,再到用户自己的 GitHub 仓库里触发同步工作流:拉取、合并、推到 `main`,然后 Cloudflare Workers Builds 照常部署。Fork 和独立副本都能用。上游地址只是默认值,可以用 `AELIOS_UPSTREAM_URL` 改。 ## 改了什么 - **同步工作流** `.github/workflows/sync-from-dan9.yml` - 支持手动触发(workflow_dispatch)。每周的定时任务默认不跑,仓库变量 `AELIOS_AUTO_SYNC=true` 时才运行。 - 能快进就快进,不能就生成合并提交。有冲突时中止合并,什么都不推,在运行摘要里列出冲突文件和手动处理的命令。 - 上游默认 `https://git.dan9.si/Aelios-project/Aelios.git`,可以用仓库变量 `AELIOS_UPSTREAM_URL` 改。 - 如果上游改动了 `.github/workflows/`,需要仓库 secret `AELIOS_SYNC_TOKEN`(带 workflow 权限的 PAT)。没配时运行会失败,并说明该怎么配。 - **后台逻辑** - 涉及文件:`src/api/admin/deploymentUpdate.ts`、`updateGithubApp.ts`、`updateGithub.ts`。 - 用 Forgejo 的 `/api/v1/repos/<owner>/<repo>/branches/main` 取上游最新提交,再和用户仓库 `main` 比较。比较走 GitHub compare:ahead_by 判断有没有新版本,返回 404 说明用户仓库还没有这个提交。 - 按钮调用 workflow dispatch,然后跟踪这次运行,再跟踪 Cloudflare 构建,直到新提交上线。 - 更新 App 的 manifest 加了 **Actions: Read and write**。已经连接、缺这项权限的老 App,签发令牌时会退回旧权限,界面上用一句话告诉用户去哪里补这项权限。 - 删掉了「必须是 Fork」的检查。 - 仓库里还没有工作流时,界面显示三行手动更新命令。 - Forgejo 连不上时显示「暂时连不上上游」,不会误报失败。 - **迁移** `migrations/0037_admin_deployment_sync.sql`:保存同步运行的状态。 - **界面**:`ui/shell.ts` 和 `ui/scripts/deploymentUpdate.ts`,加了新的提示文案和缺工作流时的命令块。 - **文档** - README.md、README.zh-CN.md、docs/setup-with-ai.md 改为从 git.dan9.si 搬到自己的 GitHub 仓库(GitHub 导入或 clone 后 push),去掉 Deploy to Cloudflare 按钮,新增「更新到最新版」一节,内容包括后台更新、手动更新和老部署怎么迁。 - SECRETS.md 补了 `AELIOS_UPSTREAM_URL`、`AELIOS_SYNC_TOKEN`、`AELIOS_AUTO_SYNC` 的说明。 - **测试** `tests/admin-deployment-update.test.ts` 覆盖五种情况:有新版本、已是最新、缺工作流、权限不足、Forgejo 失败。`tests/settings-coverage.test.ts` 同步更新。 代码里没有写进任何人的私人地址或数据,git.dan9.si 只作为可以改的默认值出现。 ## 怎么测的 - `npm run typecheck` 通过。 - `npm test`:703 个通过,0 个失败。 - `npm run verify` 通过,包括在本地 D1 上依次应用全部迁移(含 0037)。 - `npm run lint`:0 个 error,48 个 warning,和 main 原有的一致。 - 在 bash 里模拟了工作流逻辑的四种情况:已是最新、快进、带工作流改动的合并(没有 token 时正确停下)、冲突(中止且不推送)。 - 说明:沙盒的代理拦截了 git.dan9.si 的 clone,所以测试是在 main `68025f7` 的完整副本上跑的,内容和 main 一致。工作流本身没有在真实的 GitHub Actions 上跑过,合并后建议先在自己的仓库手动触发一次确认。 ## 老用户迁移步骤 1. 在自己仓库的本地克隆里跑一次下面三行,把同步工作流和新版更新按钮一起拉进来: ```bash git remote add dan9 https://git.dan9.si/Aelios-project/Aelios.git git pull --no-rebase dan9 main git push ``` 2. 如果仓库的 **Actions** 页显示工作流被关闭(新 Fork 默认关闭),先启用。 3. 等 Cloudflare 部署完,到 GitHub **Settings → Developer settings → GitHub Apps →** Aelios 更新 App **→ Permissions**,把 **Actions** 设为 **Read and write** 并保存,再到安装页批准新权限。用 `AELIOS_UPDATE_GITHUB_TOKEN` 的,给令牌加同样的权限。 4. 可选:添加仓库 secret `AELIOS_SYNC_TOKEN`。上游改动工作流文件时需要它。 5. 可选:设置仓库变量 `AELIOS_AUTO_SYNC=true`,每周自动同步。要换上游的,把 `AELIOS_UPSTREAM_URL` 同时设成仓库变量和 Worker 变量。 之后在 `/admin` 点「更新」就行。Cloudflare 里的记忆和设置不受影响。 ## 没动的 两份 README 里指向 GitHub 上 Aelios-resident 的链接,以及 SECURITY.md 里的 issue 链接,GitHub 上也已经失效,但不在这次的范围内,没有改。 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Adds the sync-from-dan9 workflow, which pulls the upstream main into the
deployment repository's main, and the helpers the update button uses to
read the upstream from the Forgejo API.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The admin update no longer needs a GitHub parent fork. It reads the latest
upstream commit from the Forgejo API, compares it with the deployment
repository, and starts sync-from-dan9 with workflow_dispatch, following the
run until Workers Builds deploys. Repositories without the workflow get the
three manual commands instead. The GitHub App asks for Actions: write, and
older apps without it are told where to add it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The update button links to the GitHub Actions run while the sync is going,
and shows the three manual commands when the repository has no sync workflow.
Tests cover a new upstream version, an up-to-date repository, a missing
workflow, a missing Actions permission and a Forgejo outage.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The READMEs and the AI setup guide copy Aelios from git.dan9.si into the
user's own GitHub repository instead of forking a GitHub upstream, and drop
the Deploy to Cloudflare button. They explain the Update button, the sync
workflow and its settings, the three manual update commands, and how an
existing fork moves over. SECRETS.md lists the new Worker and repository
settings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
saki merged commit 557062cdcf into main 2026-11-28 22:56:56 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Aelios-project/Aelios!1
No description provided.