您的客户希望在 Lovable 中有一个单击按钮,向每个活跃用户发送更改。您已经证明了更新路径的手动工作:
npx @capgo/cli@latest bundle upload --channel=production --auto-bump
缺少的部分不是在 Lovable 中添加另一个终端命令。 Lovable 不能在发布时运行 Capgo。 当 GitHub 同步功能启用时, 发布将推送一个提交到您的仓库. GitHub Actions 将为您运行构建和 bundle upload 本指南涵盖了客户必须进行的手动设置:
添加作为 __CAPGO_KEEP_0__ 秘密。对于工作流文件,请将准备好的 AI 指令复制并粘贴到 Lovable 中(步骤 3)。 CAPGO_TOKEN as a GitHub secret. For the workflow file, copy-paste the ready AI instruction into Lovable (Step 3).
步骤
| 谁 | 步骤 1:客户添加 __CAPGO_KEEP_0__ 作为 Lovable 秘密。 | What happens to __CAPGO_KEEP_0__ |
|---|---|---|
| 1 | 客户端 | 在 Lovable 中编辑应用并点击 发布 |
| 2 | Lovable | 提交并推送到 GitHub (通常是 GitHub) main) |
| 3 | GitHub | npm ci, npm run build, bundle upload --auto-bump Capgo |
| 4 | Capgo | 已激活的设备在 __CAPGO_KEEP_1__ 中接收更新 production 无需 SSH、无需本地 __CAPGO_KEEP_0__、无需配置密钥后额外点击 |
No SSH, no local CLI, no extra click after the secret is configured.
前提条件
- 可爱项目已连接到GitHub(导出指南)
- Capacitor+
@capgo/capacitor-updater在仓库中(可爱到移动设备指南) - 应用已在Capgo中注册
capacitor.config.ts指向正确的appId production已存在并链接到用户运行的构建的频道
为什么 --auto-bump
每次Capgo上传都需要一个 新的唯一版本。Lovable Publish 不会自动更新版本号 package.json 所以,如果您重复使用相同的版本号,CI 将在第二次部署时失败。
--auto-bump Capgo 会读取最新的版本号并自动更新。 minorCapgo 的默认级别是 --auto-bump patch 您可以传递 --auto-bump major 或
Step 1 — Create a Capgo API key
- 步骤 1 — 创建一个 __CAPGO_KEEP_0__ __CAPGO_KEEP_1__ 密钥 console.capgo.app/apikeys/
- console.API.app/apikeys/
- 创建一个具有上传应用程序包权限的 __CAPGO_KEEP_0__ 密钥
复制该密钥一次。您将无法再次看到完整的值。
第 2 步 — 添加 CAPGO_TOKEN 在 GitHub (唯一的环境步骤)
这是您向 Kuldeep 和任何拥有仓库的客户发送的步骤。
- 打开 GitHub 仓库 Lovable 同步到
- 前往 设置 → 机密和变量 → 动作
- 点击 新仓库机密
- 名称:
CAPGO_TOKEN - 值:粘贴第 1 步中的 Capgo API 密钥
- 保存
GitHub 将密钥注入工作流程中,作为 ${{ secrets.CAPGO_TOKEN }}. 工作流程读取它作为环境变量 CAPGO_TOKEN environment variable for the Capgo CLI.
仓库中添加密钥。您只需在 __CAPGO_KEEP_0__ 中填入密钥,不需要在 Lovable 设置中填入。 repo. You only need the key in GitHub, not in Lovable settings.
将以下代码块复制到 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.
__CAPGO_KEEP_0__ 将密钥注入工作流程中,作为 __CAPGO_KEEP_1__ 的环境变量。 发布 因此工作流程将落地在 GitHub。
手动替代方案
如果您不想使用可爱的聊天,创建 .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 路径: 可爱的 Vite 应用程序通常需要 base: './' 在 vite.config.ts 以便资产在本机 shell 中加载。如果用户在 OTA 更新后看到白屏,请要求可爱的设置 base: './',重新发布,并让工作流程重新部署。
加密包: 如果您使用 Capgo 加密, 添加 CAPGO_PRIVATE_KEY 作为第二个 GitHub 密钥并将其传递给上传步骤。 --key-data-v2 "${{ secrets.CAPGO_PRIVATE_KEY }}" 步骤 4 — 确认发布触发部署
在 Lovable 中,创建一个小的可见变化(例如按钮标签文本)
- 点击
- 发布 在 __CAPGO_KEEP_0__ 上,打开
- On GitHub, open 并观看 步骤 4 — 确认发布会触发部署 Capgo 实时更新
- 当工作项为绿色时,打开你的__CAPGO_KEEP_0__控制台 Capgo console 在安装了应用程序的设备上,确认更新已到达(可能需要一分钟的时间,取决于频道设置)
production成功: - 在可爱的Lovable中发布 → 绿色__CAPGO_KEEP_0__动作 → __CAPGO_KEEP_1__频道中的新版本 → 用户收到更新
✅ 故障排除 Publish in Lovable → green GitHub Action → new bundle in Capgo → users get the update.
可能原因
| 修复 | __CAPGO_KEEP_0__实时更新 | __CAPGO_KEEP_0__控制台 |
|---|---|---|
| 工作流程永远不会运行 | 推送到其他分支 main |
变更 branches 工作流程或发布到 main |
CAPGO_TOKEN 认证错误 |
缺少或名称错误的密钥 | 密钥必须精确 CAPGO_TOKEN 在 Actions 密钥下 |
| 版本已经存在 | 上传重复使用了相同的捆绑包版本 | 保留 --auto-bump 在上传步骤 (或传递 --auto-bump patch) |
构建失败于 npm ci |
锁文件不一致 | 运行 npm install 本地构建, 提交 package-lock.json重新发布 |
| 上传成功, 白屏 | 错误 webDir 或 Vite base |
匹配 capacitor.config.ts webDir 到构建输出 (dist 对于 Vite) 并设置 base: './' |
| 用户无法看到更新 | 未与其构建关联的频道 | 在 Capgo 中,关联设备构建到 production 或将频道设置为公共 |
有关更多工作流模式(特性分支、PR频道、加密),请参见 GitHub Actions 集成.
您告诉客户
发送给他们这个清单
- 您 已经将 Lovable 与 GitHub 连接,并在移动应用中设置了 Capgo。
- 他们 添加一个 GitHub 密钥:
CAPGO_TOKEN使用他们的 Capgo API 密钥(apikeys 页面). - 他们 点击 在 Lovable 中发布 他们永远不会在本地运行
- 除非他们想
npx @capgo/cli这与他们要求的单击体验相符:在 Lovable 中发布是按钮; __CAPGO_KEEP_0__ Actions 和 __CAPGO_KEEP_1__ 会处理剩余的工作。
That matches the single-click experience they asked for: Publish in Lovable is the button; GitHub Actions and Capgo handle the rest.
将 Lovable 转换为 iOS 和 Android
- —— 如果您尚未将应用包装起来,则需要完整的 __CAPGO_KEEP_0__ + __CAPGO_KEEP_1__ 设置 — Full Capacitor + Capgo setup if you have not wrapped the app yet
- Publish in Lovable 是他们的按钮; GitHub Actions 和 __CAPGO_KEEP_1__ 会处理剩余的工作 —— 基于标签的发布和版本更新
- GitHub GitHub Actions 集成 —— 多渠道和预览发布渠道
- Capgo 实时更新 —— 渠道、回滚和采用统计