
PostHog 的 GitHub Actions 实战Depot 托管 Runner 的选型、缓存与调试全指南【免费下载链接】posthog:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.项目地址: https://gitcode.com/GitHub_Trending/po/posthog本文以 PostHog 仓库内置的技能文档 SKILL.md 为主体系统讲解如何把 GitHub Actions 工作负载迁移到 Depot 托管的临时、单租户 Runner 上涵盖runs-on标签的命名规则与全部机型/价格、组织上下文排查、零配置缓存Depot Cache 与 sccache/Turborepo 等预置工具、Dagger/egress 过滤/Tailscale 私有网络集成、Dependabot 特殊限制以及 SSH 调试与常见故障的处理方法。读完后你可以像 PostHog 一样用最小改动把 GitHub 托管 Runner 替换为 Depot Runner并能结合仓库内真实的 workflow 文件验证每一处配置。一、背景为什么 PostHog 的 CI/CD 跑在 Depot Runner 上Depot 提供托管的、临时的ephemeral、单租户的 GitHub Actions Runner是 GitHub 托管 Runner 的“即插即用”替代品只需把工作流里的runs-on标签改掉其余步骤代码完全不动。一个硬前提是仓库必须属于 GitHub 组织organization个人账号下的仓库不支持。PostHog 仓库本身就是一份大规模落地样本组织凭据文件 depot.json 在仓库根目录直接声明了 Depot 组织 IDx19jffd9zf供 CLI 与 CI 任务识别组织上下文大量工作流已切换为 Depot 标签例如 _rust-build-images.yml 中runs-on: depot-ubuntu-22.04cd-agent-proxy-image.yml、cd-mcp-image.yml 等使用depot-ubuntu-24.04.github/actionlint.yaml 的self-hosted-runner.labels把仓库实际用到的 Depot 标签depot-ubuntu-22.04、depot-ubuntu-24.04-4、depot-ubuntu-24.04-8、depot-ubuntu-24.04-arm-4、depot-macos-15、depot-windows-2022-4等声明给 actionlint 做静态检查避免 lint 误报未定义标签。接入三步走按技能文档给出的接入流程在 Depot 控制台进入 GitHub Actions → Connect to GitHub安装 Depot GitHub App对公共仓库到 GitHub 组织设置 → Actions → Runner groups → Default勾选 “Allow public repositories”更新工作流文件中的runs-on标签下节详述。二、多组织用户先做组织上下文检查如果用户同时属于多个 GitHub 组织而 Depot 里看不到预期的仓库、设置或 Runner先确认当前 Depot CLI 的组织上下文depot org show # 查看当前组织 ID depot org list # 列出用户所属的全部组织 depot org switch org-id # 可选设置默认组织对于支持该参数的命令还可以直接传--org org-id指向工作流/仓库所在的组织。仓库中的 depot.json 正是这类组织上下文的持久化声明CI 中引用它即可避免歧义。三、Runner 标签与机型价格标签使用单个标签格式为depot-{os}-{version}[-{arch}][-{size}]。UbuntuIntel x86AMD EPYC 平台标签CPU 核数内存磁盘每分钟价格depot-ubuntu-24.0428 GB100 GB$0.004depot-ubuntu-24.04-4416 GB130 GB$0.008depot-ubuntu-24.04-8832 GB150 GB$0.016depot-ubuntu-24.04-161664 GB180 GB$0.032depot-ubuntu-24.04-3232128 GB200 GB$0.064depot-ubuntu-24.04-6464256 GB250 GB$0.128Ubuntu 22.04 同样可用depot-ubuntu-22.04、depot-ubuntu-22.04-4等。PostHog 的 Rust 镜像构建 _rust-build-images.yml 选的就是 22.04而多数 CD 镜像工作流选 24.04可以看出两者都在生产使用。UbuntuARMGraviton4 平台规格与价格与 Intel 版一致标签加-arm后缀depot-ubuntu-24.04-arm、depot-ubuntu-24.04-arm-4、depot-ubuntu-24.04-arm-8等。PostHog 在 .github/actionlint.yaml 中声明了depot-ubuntu-24.04-arm-4说明 ARM 机型已实际进入其 CI 标签白名单。Windows Server标签CPU 核数内存每分钟价格depot-windows-202528 GB$0.008depot-windows-2025-4416 GB$0.016depot-windows-2025-8至-648–6432–256 GB$0.032–$0.256Windows Server 2022 也可用depot-windows-2022等PostHog 白名单中有depot-windows-2022-4。Windows 限制没有 Hyper-VDocker 在 Windows Runner 上不可用。macOSApple M2标签CPU 核数内存每分钟价格depot-macos-15/depot-macos-latest824 GB$0.08depot-macos-14824 GB$0.08注意 macOS不是完全弹性的它是固定资源池采用 FIFO 排队且需要 Startupplan及以上套餐。别名Aliasesdepot-ubuntu-latest→ Ubuntu 24.04depot-windows-latest→ Windows 2025depot-macos-latest→ macOS 15四、迁移只改一行 runs-on迁移的本质就是替换runs-on工作流其余部分不动jobs: build: # Before: # runs-on: ubuntu-latest # After: runs-on: depot-ubuntu-24.04-4 steps: - uses: actions/checkoutv4 - run: npm ci - run: npm test常见错误多标签# 错误 — 多个标签会导致稳定性问题 runs-on: [self-hosted, depot-ubuntu-24.04] # 正确 — 始终使用单个 Depot runner 标签 runs-on: depot-ubuntu-24.04-4PostHog 的 actionlint.yaml 只声明单个 Depot 标签给检查器也和这条“单标签”纪律一致。五、缓存Depot Cache 与预置构建工具自动接入 Depot Cache任何使用 GitHub Actions cache API 的动作会自动走Depot Cache无需改配置。包括actions/cache、actions/setup-node、actions/setup-python、actions/setup-java以及一切基于actions/cache的动作。缓存行为特性来自技能文档以仓库repository为作用域无分支隔离不同分支共享同一缓存键空间加密存储吞吐可达 1000 MiB/s保留期可配置7 / 14 / 30 天。关闭方式组织设置中关掉 “Allow Actions jobs to automatically connect to Depot Cache”。零配置的构建工具缓存工具预置内容Turborepo已设置TURBO_API环境变量——直接运行turbo build即可Bazel~/.bazelrc已预填——直接bazel build //...sccache已设置SCCACHE_WEBDAV_ENDPOINT——配合RUSTC_WRAPPER: sccache使用Mavensettings.xml已预填缓存 ID 为depot-cachePantspants.toml已配置——直接pants package ::moonrepo环境变量已设置——直接moon run buildPostHog 对 sccache 的实际用法在 _rust-build-images.yml 中值得细读该工作流在depot-ubuntu-22.04上构建多平台 Docker 镜像先把SCCACHE_WEBDAV_ENDPOINT/SCCACHE_WEBDAV_TOKEN从环境变量读出并::add-mask::打码再以 build-args/secrets 注入 depot/build-push-actionbuild-args: | SCCACHE_LOGdebug SCCACHE_NO_DAEMON1 SCCACHE_WEBDAV_KEY_PREFIX${{ steps.sccache.outputs.cache-key-prefix }} secrets: | SCCACHE_WEBDAV_ENDPOINT${{ steps.sccache.outputs.endpoint }} SCCACHE_WEBDAV_TOKEN${{ steps.sccache.outputs.token }}其中cache-key-prefix用hashFiles(rust/Cargo.lock)生成让远端缓存键跟随 Rust 依赖锁文件变化此外还有一个务实细节——fork PR 会主动跳过 sccache 凭据降级为无远端缓存的构建避免向外部 fork 泄露 WebDAV token。ci-nodejs.yml 则通过仓库内的可复用动作./.github/actions/setup-sccache完成安装模式相同。这些细节印证了技能文档中“SCCACHE_WEBDAV_ENDPOINT已设置、配合RUSTC_WRAPPER: sccache”这一条的落地方式。六、Dagger 集成已弃用技能文档明确标注Dagger Engine 在 Depot GitHub Actions Runner 上的支持正在弃用未来版本会移除不建议在新工作流中使用该集成。历史用法如下仅供维护旧工作流时参考runs-on: depot-ubuntu-latest,dagger0.15.1该写法会启动一个带持久 NVMe 缓存的独立 Dagger Engine VMDagger CLI 预装额外收费 $0.04/min。新工作流请直接使用普通 Depot 标签。七、Egress 出站过滤仅 Linux在组织设置 → GitHub Actions Runners → Egress Rules 中配置先设默认规则为 Allow 或 Deny再为 IP、CIDR 或主机名添加具体的 allow/deny 规则。两条限制macOS 和 Windows 不支持与 Tailscale 不兼容需要内网访问时请走下一节的 Tailscale 方案而不是叠加出站过滤。八、用 Tailscale 访问私有端点当 Job 需要访问私有服务内部 API、数据库、私有子网且不想维护静态 IP 白名单时推荐用 Tailscale。在 Depot 上的工作方式Depot Runner 在 Job 启动时作为临时节点加入你的 tailnet访问控制完全交给你的 Tailscale ACL推荐标签tag:depot-runner仅为了连接私有端点不需要改动任何 workflow YAML。配置步骤在 Tailscale ACL 的tagOwners下创建 Runner 标签例如tag:depot-runner创建 Tailscale OAuth 客户端具备Keys Auth Keys写权限并选择该标签在 Depot 组织设置的 Tailscale 设置中用 OAuth client ID/secret 连接添加允许tag:depot-runner访问目标主机/子网的 ACL。ACL 示例——按主机名放行{ acls: [ { action: accept, src: [tag:depot-runner], dst: [database-hostname] } ] }按 CIDR 与端口范围放行{ acls: [ { action: accept, src: [tag:depot-runner], dst: [192.0.2.0/24:*] } ] }九、Dependabot 在 Depot Runner 上运行在 GitHub 组织设置中开启 “Dependabot on self-hosted runners”Dependabot 的 Job 会自动跑在depot-ubuntu-latest上。重要限制Dependabot 不支持 OIDC。需要用token:输入配合DEPOT_TOKENsecret而不是id-token换令牌的方式。这也是 PostHog 工作流里普遍显式声明permissions: id-token: write如 _rust-build-images.yml之外Dependabot 场景需要单独绕开 OIDC 的原因。十、SSH 调试tmate 实战技巧在失败时开一个可 SSH 的控制台是最直接的调试手段技能文档给出的标准写法steps: - uses: actions/checkoutv4 - uses: mxschmitt/action-tmatev3 - run: npm testPostHog 后端测试工作流 ci-backend.yml 里保留了这段被注释的调试模板并提示可以放宽该工作流的超时以留出 tmate 会话时间# Uncomment this code to create an ssh-able console so you can debug issues with github actions # - name: Setup tmate session # if: failure() # uses: mxschmitt/action-tmatev3这种“保留注释模板”的方式很实用需要调试时取消注释即可平时不影响流水线。十一、故障排查速查表错误现象处理方法No space left on device操作系统本身占用约 70 GB 磁盘升级更大规格 Runner或在工作流里清理磁盘Lost communication with server查看 Depot 状态页检查组织用量上限usage capsOperation was canceled可能是手动取消、concurrency 的 cancel-in-progress或 OOM——到 Dashboard 查看内存情况Unable to get ACTIONS_ID_TOKEN_REQUEST_URLDependabot 不支持 OIDC——改用DEPOT_TOKENsecret工作流不启动确认只用了单个 Runner 标签确认 Runner group 允许该仓库核对 Depot GitHub App 权限工作流卡死用 GitHub API 强制取消POST /repos/{owner}/{repo}/actions/runs/{id}/force-cancel十二、小结从文档到仓库的完整落地闭环把技能文档与仓库实物对照可以提炼出 PostHog 使用 Depot 的四条纪律可直接复制到你的仓库单标签runs-on永远只写一个 Depot 标签规格用标签后缀表达-4、-8、-arm等组织显式化用 depot.json 与depot org命令显式管理组织上下文多组织环境下先用depot org show排错吃透零配置缓存优先依赖 Depot Cache 与 Turborepo/sccache/Bazel 等预置工具需要 sccache 时参照 _rust-build-images.yml 的凭据传递与 fork 降级模式标签白名单进 lint把实际使用的 Depot 标签写进 .github/actionlint.yaml 的self-hosted-runner.labels让 actionlint 持续校验工作流不漂移。配套能力上出站过滤只做 Linux私网访问走 Tailscale tag:depot-runnerACLDependabot 记得绕开 OIDC 用DEPOT_TOKEN调试用 tmate卡死用 force-cancel API。这套组合就是 PostHog 在 GitHub Actions 上使用 Depot 托管 Runner 的完整方法论。【免费下载链接】posthog:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.项目地址: https://gitcode.com/GitHub_Trending/po/posthog创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考