: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
# Git and the API must still be up: the checkout clones from GitHub, and Depot
# resolves the dispatch through the API. Depot finds this workflow only if the
# file is on master, but it runs the dispatched ref's copy of it.
# Runbook: https://wiki.posthog.com/operations/deployments/deploy-during-github-outage
#
# Pushes to posthog-cloud-prs because the posthog-cloud publish role is trusted
# through the GitHub OIDC issuer, which Depot CI cannot present: Depot mints its
# own tokens from identity.depot.dev, so that role is out of reach at every ref.
# The Depot role trusts any ref on purpose, which is why it can only reach the
# -prs repositories. Widening it is not the fix.
name: Actions outage image build
on:
workflow_dispatch:
jobs:
build:
name: Build and push to ECR
runs-on: depot-ubuntu-24.04
timeout-minutes: 45
permissions:
id-token: write
contents: read
steps:
- name: Check out
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Depot CLI
uses: depot/setup-action@15c09a5f77a0840ad4bce955686522a257853461 # v1.7.1
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@ec61189d14ec14c8efccab744f656cffd0e33f37 # v6.1.0
with:
role-to-assume: ${{ vars.DEPOT_POSTHOG_PRS_PUBLISH_IAM_ROLE }}
aws-region: us-east-1
- name: Login to Amazon ECR
id: aws-ecr
uses: aws-actions/amazon-ecr-login@f2e9fc6c2b355c1890b65e6f6f0e2ac3e6e22f78 # v2.1.2
# The Dockerfile pulls node, python and debian from Docker Hub. Depot forwards the
# credentials from this sandbox to the remote builder, so logging in here keeps those
# base image pulls off the anonymous per-IP rate limit. The images are public, so a
# missing secret or a failed login falls back to anonymous pulls and does not stop
# the outage build.
- name: Login to Docker Hub
if: ${{ vars.DOCKERHUB_USER != '' && secrets.DOCKERHUB_TOKEN != '' }}
continue-on-error: true
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
username: ${{ vars.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Same step as in container-images-cd.yml, so an image built during an outage links
# backend exceptions to its release like a normal build does. Never blocks the build:
# without the secret the action passes with an empty id, and continue-on-error plus the
# timeout cover a failed or hung call. An empty id is fine: the SDK treats a blank value
# as unset.
- name: Resolve error tracking release
id: release
continue-on-error: true
timeout-minutes: 5
uses: PostHog/resolve-release@52d3bea6f86a713545874057b7d4bfebb6b5f367 # v1.0.0
with:
api-key: ${{ secrets.POSTHOG_UPLOAD_SOURCEMAPS_CLI_API_KEY }}
project-id: '2'
release-name: posthog
release-version: ${{ github.sha }}
- name: Build and push
id: build
uses: depot/build-push-action@5f3b3c2e5a00f0093de47f657aeaefcedff27d18 # v1.17.0
with:
context: .
tags: ${{ steps.aws-ecr.outputs.registry }}/posthog-cloud-prs:${{ github.sha }}
platforms: linux/amd64,linux/arm64
# The GITHUB_* args become the git metadata on the error tracking release the
# sourcemap upload stage resolves, and creates when the release step above could
# not. That stage builds in a container with no .git directory, so the workflow
# has to hand them in (see Dockerfile).
build-args: |
COMMIT_HASH=${{ github.sha }}
POSTHOG_RELEASE_ID=${{ steps.release.outputs.release-id }}
GITHUB_ACTIONS=true
GITHUB_SHA=${{ github.sha }}
GITHUB_REF_NAME=${{ github.ref_name }}
GITHUB_REPOSITORY=${{ github.repository }}
GITHUB_SERVER_URL=${{ github.server_url }}
push: true
# Without the upload the Dockerfile keeps the .map files in the image.
secrets: |
posthog_upload_sourcemaps_cli_api_key=${{ secrets.POSTHOG_UPLOAD_SOURCEMAPS_CLI_API_KEY }}
# This branch never ran CI, so a fatal import must fail here rather than
# crash-loop in production. Web alone is not enough: temporal and celery
# import product code that django.setup() skips.
- name: Verify image boots and report
env:
IMAGE: ${{ steps.aws-ecr.outputs.registry }}/posthog-cloud-prs@${{ steps.build.outputs.digest }}
TAG: ${{ github.sha }}
run: |
docker run --rm \
-e SKIP_SERVICE_VERSION_REQUIREMENTS=1 \
-e STATIC_COLLECTION=1 \
-e DATABASE_URL=postgres:/// \
-e REDIS_URL=redis:/// \
-e INTERNAL_API_SECRET=ci-boot-test-dummy-secret \
"$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
'
{
echo "## Image ready"
echo
echo "Tag for the ArgoCD image override input: \`$TAG\`"
echo
echo "Digest for a live manifest edit: \`$IMAGE\`"
echo
echo "Runbook: https://wiki.posthog.com/operations/deployments/deploy-during-github-outage"
} | tee -a "$GITHUB_STEP_SUMMARY"