你的客户希望在 Lovable 中有一个按钮,即可将更改发布给所有活跃用户。你已经手动验证过更新流程是可行的:
npx @capgo/cli@latest bundle upload --channel=production --auto-bump
缺的那一环,并不是在 Lovable 里再敲一条终端命令。 Lovable 无法在 Publish 时运行 Capgo。 启用 GitHub 同步后, Publish 会把一个 commit 推送到你的仓库。GitHub Actions 会运行构建并 bundle upload 来为你完成操作。
本指南只涵盖你的客户必须手动做一次的那项设置:添加 CAPGO_TOKEN 作为 GitHub secret。至于 workflow 文件,把现成的 AI 指令复制粘贴到 Lovable(步骤 3)。
Pipeline 工作原理
| 步骤 | 谁 | 会发生什么 |
|---|---|---|
| 1 | 客户端 | 在 Lovable 中编辑应用并点击 发布 |
| 2 | Lovable | 提交并推送到 GitHub(通常是 main) |
| 3 | GitHub 操作 | npm ci, npm run build, bundle upload --auto-bump 到 Capgo |
| 4 | Capgo | 上的活跃设备 production 通道接收更新 |
无需 SSH,无需本地 CLI,配置好密钥后无需额外点击。
前提条件
- Lovable 项目已连接到 GitHub(导出指南)
- Capacitor +
@capgo/capacitor-updater在仓库中(Lovable 转移动端指南中描述的设置相同) - 应用已在 Capgo 中注册,且
capacitor.config.ts指向正确的appId productionchannel 已存在,并关联到用户运行的构建
原因 --auto-bump
每次 Capgo 上传都需要一个 新的唯一 bundle 版本。Lovable Publish 不会自动递增 package.json 为您处理,因此如果您复用相同版本,CI 在第二次部署时会失败。
--auto-bump 读取通道(或应用)上的最新版本并递增。默认级别为 minor。您可以传入 --auto-bump patch 或 --auto-bump major 如果你愿意的话。
第 1 步 — 创建 Capgo API 密钥
- 打开 console.capgo.app/apikeys/
- 创建一个 API key,授予其为你的应用上传 bundle 的权限
- 请复制该 key。完整值之后不会再显示。
请像对待密码一样对待此 key。切勿将其 commit 到 Git,也不要粘贴到 Lovable chat 中。
第 2 步 — 添加 CAPGO_TOKEN 在 GitHub 中(唯一的 env 步骤)
这就是你要发给 Kuldeep 以及任何拥有该 repo 的客户的步骤。
- 打开 Lovable 同步到的 GitHub 仓库
- 前往 设置 → Secrets 和变量 → 操作
- 点击 新的仓库密钥
- 名称:
CAPGO_TOKEN - 值:粘贴第 1 步中的 Capgo API 密钥
- 保存
GitHub 将密钥注入工作流,作为 ${{ secrets.CAPGO_TOKEN }}。以下工作流将其读取为 CAPGO_TOKEN 环境变量,用于 Capgo CLI。
如果仓库位于您的客户组织下,他们必须在 其 仓库中添加密钥。您只需在 GitHub 中拥有密钥,无需在 Lovable 设置中配置。
第 3 步 — 把这段 prompt 粘贴到 Lovable
将以下代码块复制到 Lovable 聊天中。如果您的默认分支不是 main,请将 main 工作流中的内容替换为您的分支名称。
Add Capgo Live Updates CI with GitHub Actions.
Create `.github/workflows/capgo-live-updates.yml` (create folders if needed). Start from this YAML, then adapt install/build to this project while keeping Capgo upload + CAPGO_TOKEN secret behavior:
name: Capgo Live Updates
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '24'
cache: 'npm'
- name: Install and build
run: |
npm ci
npm run build
- name: Upload bundle to Capgo
run: npx @capgo/cli@latest bundle upload --channel=production --auto-bump
env:
CAPGO_TOKEN: ${{ secrets.CAPGO_TOKEN }}
Rules:
- Do not hardcode any Capgo API key in the repo or in chat.
- The workflow must read CAPGO_TOKEN only from GitHub Actions secrets (`${{ secrets.CAPGO_TOKEN }}`).
- Keep `--auto-bump` on the upload command so each Publish gets a new unique bundle version.
- Prefer the project's real production build script from package.json (for example `npm run build` or `vite build`).
- If package-lock.json is missing, use `npm install` instead of `npm ci`.
- Do not modify app UI or Capacitor config for this task.
- Commit the workflow file so the next Publish pushes it to GitHub.
Lovable 应用更改后,点击 发布 以便工作流部署到 GitHub。
手动替代方案
如果你不想使用 Lovable 聊天,请创建 .github/workflows/capgo-live-updates.yml 仅包含此 YAML(不含提示词文本)。如果你的项目有所不同,请按照上述规则调整安装/构建步骤,然后提交并推送。
name: Capgo Live Updates
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '24'
cache: 'npm'
- name: Install and build
run: |
npm ci
npm run build
- name: Upload bundle to Capgo
run: npx @capgo/cli@latest bundle upload --channel=production --auto-bump
env:
CAPGO_TOKEN: ${{ secrets.CAPGO_TOKEN }}
Vite base 路径: Lovable Vite 应用通常需要 base: './' 中的 vite.config.ts 以便资源在原生壳内加载。如果用户在 OTA 更新后看到白屏,请让 Lovable 设置 base: './',重新发布,并让工作流重新部署。
加密 bundle: 如果你使用 Capgo 加密,添加 CAPGO_PRIVATE_KEY 作为第二个 GitHub 密钥并传递 --key-data-v2 "${{ secrets.CAPGO_PRIVATE_KEY }}" 在上传步骤中。
第 4 步 — 确认 Publish 会触发部署
- 在 Lovable 中,做一个小的可见更改(例如按钮标签文本)
- 点击 发布
- 在 GitHub 上,打开 操作 并观察 Capgo Live Update
- 当任务显示为绿色时,打开您的 Capgo 控制台 并确认在
production渠道 - 在已安装该应用的设备上,确认更改已生效(根据渠道设置,可能需要一分钟)
✅ 成功: 在 Lovable 中发布 → 绿色的 GitHub Action → Capgo 中出现新 bundle → 用户收到更新。
故障排除
| 现象 | 可能原因 | 修复 |
|---|---|---|
| 工作流从未运行 | 推送到了除 main |
变更 branches 之外的分支,或发布到 main |
CAPGO_TOKEN / 认证错误 |
Secret 缺失或名称错误 | Secret 必须严格为 CAPGO_TOKEN 位于 Actions secrets 下 |
| 版本已存在 | 上传时复用了相同的 bundle 版本 | 保留 --auto-bump 在上传步骤中(或传入 --auto-bump patch) |
构建在 npm ci |
Lockfile 不同步 | 运行 npm install 本地,提交 package-lock.json,再次发布 |
| 上传成功,白屏 | 错误 webDir 或 Vite base |
匹配 capacitor.config.ts webDir 到构建输出(dist 用于 Vite)并设置 base: './' |
| 用户看不到更新 | Channel 未关联到其构建 | 在 Capgo 中,将设备构建链接到 production 或将通道设置为公开 |
更多工作流模式(功能分支、PR 通道、加密),请参阅 GitHub Actions 集成.
你可以这样告诉你的客户
将此检查清单发送给他们:
- 您 已将 Lovable 连接到 GitHub,并在移动应用上配置了 Capgo。
- 他们 添加一个 GitHub 密钥:
CAPGO_TOKEN使用他们的 Capgo API 密钥(apikeys 页面). - 他们 点击 发布 在 Lovable 中,随时让用户接收更新。
- 除非有意为之,否则他们从不在本地运行
npx @capgo/cli。
这正符合他们要求的单步体验:Lovable 中的发布是按钮;GitHub Actions 和 Capgo 负责其余部分。
继续
- 将 Lovable 转换为 iOS 和 Android — 完整的 Capacitor + Capgo 设置(如果你尚未封装应用)
- 使用 GitHub Actions 自动 build 和 release — 基于标签的发布和版本升级
- GitHub Actions 集成 — 多通道和 PR 预览通道
- Capgo Live Update — 通道、回滚和采用统计