Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

fix: bootstrap upstream sync for one-click deployments

tianma-if63050054f705
diff --git a/.github/workflows/sync-edgeever-upstream.yml b/.github/workflows/sync-edgeever-upstream.yml
index 8621f26d..a3ca9e47 100644
--- a/.github/workflows/sync-edgeever-upstream.yml
+++ b/.github/workflows/sync-edgeever-upstream.yml
@@ -64,14 +64,31 @@ jobs:
target_commit="$(git rev-parse "${target_ref}^{commit}")"
if git merge-base --is-ancestor "${target_commit}" HEAD; then
update_required=false
+ bootstrap_required=false
else
update_required=true
+ bootstrap_required=false
+
+ # Cloudflare Deploy buttons create a fresh repository with a
+ # synthetic `source repo import` commit instead of preserving the
+ # upstream Git history. The first update must connect that import
+ # history to upstream before normal merges can work. Only do this
+ # automatically when the downstream repository contains no changes
+ # beyond the updater workflow itself; otherwise fail closed and ask
+ # the owner to resolve the customized repository manually.
+ root_commit="$(git rev-list --max-parents=0 HEAD)"
+ root_subject="$(git show -s --format=%s "${root_commit}")"
+ non_workflow_changes="$(git diff --name-only "${root_commit}" HEAD -- ':!.github/workflows/sync-edgeever-upstream.yml')"
+ if [ "${root_subject}" = "source repo import" ] && [ -z "${non_workflow_changes}" ]; then
+ bootstrap_required=true
+ fi
fi
{
echo "target_ref=${target_ref}"
echo "target_commit=${target_commit}"
echo "update_required=${update_required}"
+ echo "bootstrap_required=${bootstrap_required}"
} >> "${GITHUB_OUTPUT}"
- name: Merge upstream update
@@ -79,10 +96,16 @@ jobs:
env:
TARGET_COMMIT: ${{ steps.upstream.outputs.target_commit }}
TARGET_REF: ${{ steps.upstream.outputs.target_ref }}
+ BOOTSTRAP_REQUIRED: ${{ steps.upstream.outputs.bootstrap_required }}
run: |
git config user.name "edgeever-updater[bot]"
git config user.email "edgeever-updater[bot]@users.noreply.github.com"
- git merge --no-edit -m "chore: update EdgeEver from ${TARGET_REF}" "${TARGET_COMMIT}"
+ if [ "${BOOTSTRAP_REQUIRED}" = "true" ]; then
+ git merge --allow-unrelated-histories --no-edit -X theirs \
+ -m "chore: initialize EdgeEver history from ${TARGET_REF}" "${TARGET_COMMIT}"
+ else
+ git merge --no-edit -m "chore: update EdgeEver from ${TARGET_REF}" "${TARGET_COMMIT}"
+ fi
- name: Set up Bun
if: steps.upstream.outputs.update_required == 'true'
diff --git a/docs/cloudflare-workers-builds.md b/docs/cloudflare-workers-builds.md
index 2f8f7b1b..dcdb681b 100644
--- a/docs/cloudflare-workers-builds.md
+++ b/docs/cloudflare-workers-builds.md
@@ -44,3 +44,5 @@ If the command reports that no deployment API token is available, open **Worker*
After setup, every push to `main` makes Cloudflare install dependencies, check and build the app, apply new D1 migrations, deploy the Worker, and verify the result. For the official Demo Worker, publishing a formal Release triggers an immediate deployment from that Release tag through the `Deploy Demo on Release` GitHub workflow; this workflow only runs in the canonical upstream repository. Other self-hosted deployment repositories can use the **Update deployed EdgeEver** workflow, which checks upstream daily: `stable` follows formal Releases by default, while the repository variable `EDGE_EVER_UPDATE_CHANNEL=edge` follows upstream `main`. No Cloudflare deployment secrets or local redeployment are required in GitHub Actions.
If a build fails, inspect its log in the Worker **Deployments** tab. Rerun `bun run deploy:builds:setup` when instance settings change.
+
+Deploy-button repositories begin with a synthetic `source repo import` commit. The first upstream update detects this layout and establishes the upstream history automatically. For repositories created before the updater workflow was introduced, add the current `.github/workflows/sync-edgeever-upstream.yml` from the upstream repository and run it manually once. Do not use this bootstrap path after custom application changes have been committed without reviewing the differences.
diff --git a/docs/cloudflare-workers-builds.zh-CN.md b/docs/cloudflare-workers-builds.zh-CN.md
index 74360195..e8186642 100644
--- a/docs/cloudflare-workers-builds.zh-CN.md
+++ b/docs/cloudflare-workers-builds.zh-CN.md
@@ -44,3 +44,5 @@ EDGE_EVER_BUILDS_API_TOKEN=<token>
配置完成后,任何推送到 `main` 的提交都会让 Cloudflare 安装依赖、检查并构建应用、执行新的 D1 migration、部署 Worker 并验证结果。官方 Demo Worker 在发布正式 Release 时,会通过 GitHub 的 `Deploy Demo on Release` 工作流从 Release 标签立即部署;该工作流只在官方上游仓库执行。其他自托管部署仓库可以使用 **Update deployed EdgeEver** 工作流每天检查上游:默认 `stable` 跟随正式 Release,设置 Repository Variable `EDGE_EVER_UPDATE_CHANNEL=edge` 后跟随上游 `main`。GitHub Actions 不需要保存 Cloudflare 部署 Secret,也不需要本地重新部署。
构建失败时,在 Worker 的 **Deployments** 页面查看日志。实例配置变化后,重新执行 `bun run deploy:builds:setup`。
+
+一键部署生成的仓库最初只有一个合成的 `source repo import` 提交。第一次上游更新会识别这种结构,并自动建立上游 Git 历史。对于更新工作流加入之前创建的仓库,请从上游仓库添加当前的 `.github/workflows/sync-edgeever-upstream.yml`,提交到 `main`,然后手动运行一次。若仓库已经提交过自定义应用代码,必须先审查差异,不要直接使用该初始化路径。
diff --git a/docs/deploy-cloudflare-button.md b/docs/deploy-cloudflare-button.md
index b3b9a813..b3b59a3f 100644
--- a/docs/deploy-cloudflare-button.md
+++ b/docs/deploy-cloudflare-button.md
@@ -25,6 +25,8 @@ To follow the latest upstream `main` instead, create a GitHub repository variabl
GitHub may delay scheduled workflows and may disable them for an inactive public repository. If daily updates stop, open the repository's **Actions** tab, enable **Update deployed EdgeEver**, and run it manually once. Do not force-push over update conflicts; resolve them or return to an unmodified deployment repository.
+The updater also bootstraps repositories created by the Cloudflare Deploy button. Those repositories start with a synthetic `source repo import` commit instead of the upstream Git history, so the first successful update creates the history connection automatically. If the repository was created before the updater workflow was added, copy the current `.github/workflows/sync-edgeever-upstream.yml` from upstream into the repository, commit it to `main`, and run it manually once from **Actions**. The bootstrap is safe only for an unmodified deployment repository; customized repositories must be reconciled manually first.
+
## Alternative Entry Points
- Use [AI Agent Cloudflare Deployment](agent-deploy-cloudflare.md) when an agent should perform the same deterministic CLI deployment with custom configuration.
diff --git a/docs/deploy-cloudflare-button.zh-CN.md b/docs/deploy-cloudflare-button.zh-CN.md
index b9ab7eb8..a782e3f0 100644
--- a/docs/deploy-cloudflare-button.zh-CN.md
+++ b/docs/deploy-cloudflare-button.zh-CN.md
@@ -25,6 +25,8 @@ EdgeEver 采用安全关闭策略。D1 migration 或鉴权 Secret 缺失时,
GitHub 的定时任务可能延迟,也可能因公共仓库长期无活动而被停用。如果每日更新停止,请打开仓库的 **Actions** 页面,启用 **Update deployed EdgeEver** 并手动运行一次。遇到更新冲突时不要 force push,应解决冲突或恢复为未定制的部署仓库。
+该更新工作流也支持 Cloudflare 一键部署生成的仓库。此类仓库最初只有一个合成的 `source repo import` 提交,并不包含上游 Git 历史;第一次成功更新时,工作流会自动建立与上游的历史连接。如果仓库是在更新工作流加入之前创建的,请从上游复制当前的 `.github/workflows/sync-edgeever-upstream.yml` 到该仓库,提交到 `main`,然后在 **Actions** 中手动运行一次。该自动初始化仅适用于未定制的部署仓库;已经修改过代码的仓库需要先人工处理差异。
+
## 其他部署入口
- 需要由 Agent 使用自定义配置执行同一套确定性 CLI 部署时,使用 [AI Agent Cloudflare Deployment](agent-deploy-cloudflare.md)。
diff --git a/tests/deployment-entrypoints.test.ts b/tests/deployment-entrypoints.test.ts
index 5e2c6f8e..55218422 100644
--- a/tests/deployment-entrypoints.test.ts
+++ b/tests/deployment-entrypoints.test.ts
@@ -41,5 +41,8 @@ describe("Cloudflare deployment entrypoints", () => {
expect(workflow).toContain("bun run db:migrate:local");
expect(workflow).toContain("bun test");
expect(workflow).toContain("git push origin HEAD:main");
+ expect(workflow).toContain("source repo import");
+ expect(workflow).toContain("--allow-unrelated-histories");
+ expect(workflow).toContain("non_workflow_changes");
});
});