Skip to content

: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.

chore(ci): skip the image build on desktop-only master pushes (#98111)

Paul D'Ambra86f1cc6726a2
diff --git a/.dockerignore b/.dockerignore
index 1322e432b1ce..3bff2f7a3ea0 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -88,6 +88,8 @@ packages/llm-normalizer/**/dist
products/**/node_modules
# Nested standalone workspace, not imported by any server image; `!products` above
# would otherwise pull ~56 MiB of desktop assets into every image build context.
+# The `changes` job in container-images-cd.yml mirrors these lines to decide whether a push
+# can change the image, so keep the two in step.
products/desktop/*
!products/desktop/packages
products/desktop/packages/*
diff --git a/.github/workflows/container-images-cd.yml b/.github/workflows/container-images-cd.yml
index 79c2736c1475..8d2a3f8db472 100644
--- a/.github/workflows/container-images-cd.yml
+++ b/.github/workflows/container-images-cd.yml
@@ -13,6 +13,15 @@ on:
push:
branches:
- master
+ # Desktop-only pushes are filtered out in the `changes` job below, not here.
+ # GitHub reads only the first 3,000 files of a push diff for a trigger-level
+ # path filter, and skips the workflow when the paths that match the filter
+ # fall outside that window. The limit is the one in "Git diff comparisons" at
+ # https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax
+ # — note the neighbouring commit-count and diff-timeout limits always run the
+ # workflow, so this is the one that skips. The desktop tree is larger than that window, so a
+ # push that rewrites most of it could drop the image build and every deploy
+ # for a backend change in the same push, with no failed run to show it.
paths-ignore:
- 'rust/**'
- 'livestream/**'
@@ -40,12 +49,63 @@ env:
ECR_REPOSITORY: posthog-cloud
jobs:
+ changes:
+ name: Check whether the push can change the image
+ # Org check only, because this job detects changes rather than pushing an
+ # image or dispatching a deploy, so the CD_DEPLOY_ENABLED gate belongs on
+ # posthog_build instead. Push only, because a manual dispatch carries no push
+ # range for the filter to read, and posthog_build already always builds there.
+ if: github.repository_owner == 'PostHog' && github.event_name == 'push'
+ runs-on: ubuntu-24.04
+ timeout-minutes: 5
+ permissions:
+ contents: read
+ outputs:
+ image: ${{ steps.filter.outputs.image }}
+ agent_shadow: ${{ steps.filter.outputs.agent_shadow }}
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ sparse-checkout: .github/actions/paths-filter
+ sparse-checkout-cone-mode: false
+
+ # On a push the action diffs the whole push range with local git, which has
+ # no file cap, so it also reads a batch push that carries several commits.
+ # continue-on-error covers a failing filter step: it publishes no verdict,
+ # and the empty value builds.
+ - uses: ./.github/actions/paths-filter
+ id: filter
+ continue-on-error: true
+ with:
+ # `.dockerignore` strips every desktop path from the image build
+ # context except agent-shadow, so a change anywhere else under
+ # products/desktop cannot alter the image. An exclude cannot be
+ # reversed inside one filter, so agent-shadow needs its own.
+ filters: |
+ image:
+ - '**'
+ - '!products/desktop/**'
+ agent_shadow:
+ - 'products/desktop/packages/agent-shadow/**'
+
posthog_build:
name: Build and push PostHog
+ needs: changes
outputs:
image-digest: ${{ steps.image.outputs.digest }}
# Production build/deploy runs only from the canonical deploy repo (CD_DEPLOY_ENABLED).
- if: github.repository_owner == 'PostHog' && vars.CD_DEPLOY_ENABLED == 'true'
+ # A push that only touches desktop code skips the build and its deploy fan-out.
+ # Every other verdict builds, including the empty one left by a `changes` job
+ # that failed, timed out, or lost its runner, so an unresolved verdict costs one
+ # build instead of a missed deploy. `!cancelled()` is what keeps that true: a
+ # condition carrying no status function gets an implicit `success()` over
+ # `needs`, which skips this job whenever `changes` did not succeed. Cancelling
+ # the run still stops the build, which `always()` would not.
+ if: |
+ !cancelled() && github.repository_owner == 'PostHog' && vars.CD_DEPLOY_ENABLED == 'true' && (
+ needs.changes.outputs.image != 'false' ||
+ needs.changes.outputs.agent_shadow == 'true'
+ )
runs-on: depot-ubuntu-24.04
# Covers two bounded build attempts plus the post-build image-boot verification before
# dispatch.