: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(ci): gate prod deploy dispatch on backend tests (#61012)
Julian Bez1e31ebb6777a
diff --git a/.github/workflows/container-images-cd.yml b/.github/workflows/container-images-cd.ymlindex 9f9c2ad06ace..102198f3e8cd 100644--- a/.github/workflows/container-images-cd.yml+++ b/.github/workflows/container-images-cd.yml@@ -23,11 +23,14 @@ jobs:name: Build and push PostHogif: github.repository == 'PostHog/posthog'runs-on: depot-ubuntu-latest- timeout-minutes: 30+ # 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: 75permissions:id-token: write # allow issuing OIDC tokens for this workflow runcontents: read # allow at least reading the repo contents, add other permissions if necessarypackages: write # allow push to ghcr.io+ checks: read # allow reading backend CI check results to gate the deploysteps:- name: Check out@@ -87,6 +90,43 @@ jobs:event: 'posthog-image-build'properties: '{"status": "failure", "commit_hash": "${{ github.sha }}"}'+ # 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. Cross-workflow+ # check-waiting on the same SHA mirrors the pattern in ci-hobby.yml.+ - name: Wait for backend tests 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: fountainhead/action-wait-for-check@5a908a24814494009c4bb27c242ea38c93c593be # v1.2.0+ with:+ token: ${{ secrets.GITHUB_TOKEN }}+ checkName: Django Tests Pass+ ref: ${{ github.sha }}+ timeoutSeconds: 2700+ intervalSeconds: 30++ - name: Block deploy if backend tests did not pass+ if: github.event_name == 'push'+ env:+ BACKEND_CONCLUSION: ${{ steps.wait-for-backend.outputs.conclusion }}+ run: |+ conclusion="$BACKEND_CONCLUSION"+ # `skipped` = the backend suite didn't run for this commit; nothing to gate on.+ if [ "$conclusion" = "skipped" ]; then+ echo "Backend tests skipped for this commit — proceeding with deploy."+ exit 0+ fi+ if [ "$conclusion" != "success" ]; then+ echo "::error::Backend CI for this commit is '${conclusion:-incomplete/timed out}'. Not deploying."+ echo "Fix CI and re-run, or trigger this workflow via workflow_dispatch to override."+ exit 1+ fi+ echo "Backend tests passed — proceeding with deploy."+- name: get deployer tokenid: deployeruses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1