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): swap deploy gate for image boot check (#64715)

Raúl Negrón-Otero80340f0b758a
diff --git a/.github/workflows/container-images-cd.yml b/.github/workflows/container-images-cd.yml
index 629dd92e1e25..8fce83fb051a 100644
--- a/.github/workflows/container-images-cd.yml
+++ b/.github/workflows/container-images-cd.yml
@@ -24,14 +24,12 @@ jobs:
# Production build/deploy runs only from the canonical deploy repo (CD_DEPLOY_ENABLED).
if: github.repository_owner == 'PostHog' && vars.CD_DEPLOY_ENABLED == 'true'
runs-on: depot-ubuntu-latest
- # Bumped from 30: the deploy dispatch now waits for backend CI on this commit
- # before firing, so the job stays alive through the build + the wait window.
- timeout-minutes: 75
+ # Covers the build plus the post-build image-boot verification before dispatch.
+ timeout-minutes: 40
permissions:
id-token: write # allow issuing OIDC tokens for this workflow run
contents: read # allow at least reading the repo contents, add other permissions if necessary
packages: write # allow push to ghcr.io
- checks: read # allow reading backend CI check results to gate the deploy
steps:
- name: Check out
@@ -138,14 +136,12 @@ jobs:
event: 'posthog-image-build'
properties: '{"status": "failure", "commit_hash": "${{ github.sha }}"}'
- # Boot the image we're about to ship before dispatching the deploy. A file missing from the
- # build context (e.g. dropped by an over-broad .dockerignore) surfaces here as an ImportError
- # and blocks the deploy, instead of crash-looping in production. These are the same vars the
- # Dockerfile's collectstatic uses; STATIC_COLLECTION=1 in particular lets Django boot without
- # live services or a real SECRET_KEY (settings/access.py otherwise exits on the default key).
- # Runs before the backend wait so a broken image fails fast; skipped on manual
- # workflow_dispatch (break-glass), like the backend gate below.
- - name: Boot Django from the built image
+ # Boot every entrypoint before dispatching, so a fatal import error (a dropped build-context
+ # file, or a stale merge relocating a module a worker still imports) blocks the deploy instead
+ # of crash-looping in prod. Web alone isn't enough: temporal/celery import product code that
+ # django.setup() skips, so a worker-only break still boots web-green. STATIC_COLLECTION=1 lets
+ # Django boot without live services or a real SECRET_KEY. Skipped on workflow_dispatch (break-glass).
+ - name: Verify image boots (web + temporal + celery)
if: github.event_name == 'push'
env:
IMAGE: ghcr.io/posthog/posthog:${{ github.sha }}
@@ -158,48 +154,10 @@ jobs:
-e DATABASE_URL=postgres:/// \
-e REDIS_URL=redis:/// \
-e INTERNAL_API_SECRET=ci-boot-test-dummy-secret \
- "$IMAGE" sh -c 'python -c "import posthog.asgi" && python manage.py check'
-
- # Gate the deploy on backend CI. The image is already built and pushed above
- # (ci-backend.yml runs in parallel on the same commit) — we only hold the
- # deploy *dispatch* to Charts until this commit's backend suite is green.
- # A stale merge once shipped a red master commit to prod because the dispatch
- # fired regardless of test results; this is the backstop.
- - name: Wait for backend/product checks to pass
- # Only gate automatic master pushes. A manual workflow_dispatch is the
- # break-glass: it skips the wait so an operator can force a deploy.
- if: github.event_name == 'push'
- id: wait-for-backend
- uses: ./.github/actions/wait-for-check
- with:
- token: ${{ secrets.GITHUB_TOKEN }}
- checkName: Django Tests Pass
- ref: ${{ github.sha }}
- # Must outlast the longest backend job (django tests: 45m in
- # ci-backend.yml) plus its start lag, so a slow-but-green check
- # still reports before we give up and block the deploy.
- timeoutSeconds: '3300'
- intervalSeconds: '30'
-
- - name: Block deploy if backend/product checks did not pass
- if: github.event_name == 'push'
- env:
- BACKEND_CONCLUSION: ${{ steps.wait-for-backend.outputs.conclusion }}
- BACKEND_CHECK_NAME: Django Tests Pass
- run: |
- conclusion="$BACKEND_CONCLUSION"
- # `skipped` = the backend suite didn't run for this commit; nothing to gate on.
- if [ "$conclusion" = "skipped" ]; then
- echo "Required backend check \"$BACKEND_CHECK_NAME\" skipped for this commit — proceeding with deploy."
- exit 0
- fi
- if [ "$conclusion" != "success" ]; then
- echo "::error::Required backend check \"$BACKEND_CHECK_NAME\" concluded \"${conclusion:-incomplete/timed out}\". Not deploying."
- echo "Open the Backend CI aggregate check for dependency results; it lists failed, cancelled, and timed-out jobs separately."
- echo "Fix CI and rerun, or trigger this workflow via workflow_dispatch to override."
- exit 1
- fi
- echo "Required backend check \"$BACKEND_CHECK_NAME\" passed — proceeding with deploy."
+ "$IMAGE" sh -ec '
+ python -c "import posthog.asgi; import posthog.management.commands.start_temporal_worker; from posthog.celery import app; app.loader.import_default_modules()"
+ python manage.py check
+ '
- name: get deployer token
id: deployer