: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): push rust images to the shared-services ECR (#124610)
Michie6e3b022f41a
diff --git a/.github/workflows/_rust-build-images.yml b/.github/workflows/_rust-build-images.ymlindex ca746bd6358c..bc522c6cf8f1 100644--- a/.github/workflows/_rust-build-images.yml+++ b/.github/workflows/_rust-build-images.yml@@ -36,6 +36,14 @@ on:description: 'Whether to push built images to the registry'type: booleandefault: true+ ecr-repository-suffix:+ description: 'Suffix of the shared-services ECR repository (empty for <image>, -prs for <image>-prs)'+ type: string+ default: ''+ require-ecr:+ description: 'Fail a push when the shared-services ECR publish role is not set'+ type: boolean+ default: falsesecrets:POSTHOG_API_TOKEN:required: false@@ -43,6 +51,8 @@ on:required: falsePOSTHOG_UPLOAD_SYMBOLS_CLI_API_KEY:required: false+ AWS_ECR_SHARED_SERVICES_PUBLISH_IAM_ROLE:+ required: falseoutputs:digests:description: 'JSON object mapping image name to digest (empty when push is false)'@@ -90,6 +100,8 @@ jobs:include: ${{ fromJson(needs.load-matrix.outputs.matrix) }}runs-on: depot-ubuntu-22.04timeout-minutes: ${{ inputs.timeout-minutes }}+ env:+ ECR_PUBLISH_ROLE: ${{ secrets.AWS_ECR_SHARED_SERVICES_PUBLISH_IAM_ROLE }}permissions:id-token: writecontents: read@@ -131,6 +143,28 @@ jobs:username: ${{ github.actor }}password: ${{ secrets.GITHUB_TOKEN }}+ # The images also go to the shared-services ECR. Deploys pull them through the VPC+ # endpoint instead of paying NAT egress to ghcr. ECR replication copies each push to+ # eu-central-1.+ - name: Require the shared-services ECR publish role+ if: ${{ inputs.push && inputs.require-ecr && env.ECR_PUBLISH_ROLE == '' }}+ run: |+ echo "::error::The shared-services ECR publish role is not set, so the image would reach ghcr only."+ exit 1++ - name: Configure AWS credentials for the shared-services ECR+ id: ecr-credentials+ if: ${{ inputs.push && env.ECR_PUBLISH_ROLE != '' }}+ uses: aws-actions/configure-aws-credentials@ec61189d14ec14c8efccab744f656cffd0e33f37 # v6.1.0+ with:+ role-to-assume: ${{ env.ECR_PUBLISH_ROLE }}+ aws-region: us-east-1++ - name: Login to the shared-services ECR+ id: ecr+ if: ${{ steps.ecr-credentials.outcome == 'success' }}+ uses: aws-actions/amazon-ecr-login@f2e9fc6c2b355c1890b65e6f6f0e2ac3e6e22f78 # v2.1.2+- name: Docker metaid: metauses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0@@ -140,7 +174,10 @@ jobs:env:DOCKER_METADATA_ANNOTATIONS_LEVELS: indexwith:- images: ghcr.io/posthog/posthog/${{ matrix.image }}+ # One push writes the same digest to both registries.+ images: |+ ghcr.io/posthog/posthog/${{ matrix.image }}+ ${{ steps.ecr.outputs.registry && format('{0}/{1}{2}', steps.ecr.outputs.registry, matrix.image, inputs.ecr-repository-suffix) || '' }}tags: ${{ inputs.tag-rules }}labels: |org.opencontainers.image.title=posthogdiff --git a/.github/workflows/rust-docker-build.yml b/.github/workflows/rust-docker-build.ymlindex e1d5ad0ccfd0..f95041fa4773 100644--- a/.github/workflows/rust-docker-build.yml+++ b/.github/workflows/rust-docker-build.yml@@ -86,7 +86,9 @@ jobs:type=semver,pattern={{major}}.{{minor}}type=shatimeout-minutes: 30+ require-ecr: ${{ vars.CD_DEPLOY_ENABLED == 'true' }}secrets:+ AWS_ECR_SHARED_SERVICES_PUBLISH_IAM_ROLE: ${{ secrets.AWS_ECR_SHARED_SERVICES_POSTHOG_MASTER_PUBLISH_IAM_ROLE }}POSTHOG_API_TOKEN: ${{ secrets.POSTHOG_API_TOKEN }}POSTHOG_DEVEX_PROJECT_API_TOKEN: ${{ secrets.POSTHOG_DEVEX_PROJECT_API_TOKEN }}# Deliberately reuses the frontend sourcemap upload key: sourcemaps and@@ -259,17 +261,23 @@ jobs:}ordered_image_alias:- name: publish ordered image aliases+ name: publish ordered image aliases (${{ matrix.registry }})needs: build-images# Freight cadence v2 sorts releases by this tag, so every deployable rust image# gets one. Mirrors the posthog_build alias job in container-images-cd.yml,- # against ghcr instead of ECR. Best effort: a missing alias delays Freight for- # that build and never fails the deploy.+ # against ghcr and the shared-services ECR. Best effort: a missing alias delays+ # Freight for that build and never fails the deploy.+ # One job per registry, so a stalled registry cannot spend the other's timeout.+ strategy:+ fail-fast: false+ matrix:+ registry: [ghcr, ecr]if: ${{ needs.build-images.result == 'success' && needs.build-images.outputs.digests != '' && github.repository_owner == 'PostHog' && vars.CD_DEPLOY_ENABLED == 'true' && vars.ORDERED_IMAGE_ALIAS_PAUSED != 'true' && github.ref == 'refs/heads/master' }}runs-on: ubuntu-24.04timeout-minutes: 10continue-on-error: truepermissions:+ id-token: writecontents: readpackages: write@@ -344,21 +352,35 @@ jobs:uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0- name: Login to ghcr.io- if: ${{ steps.ordered-release.outputs.tag != '' }}+ if: ${{ steps.ordered-release.outputs.tag != '' && matrix.registry == 'ghcr' }}uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0with:registry: ghcr.iousername: ${{ github.actor }}password: ${{ secrets.GITHUB_TOKEN }}+ - name: Configure AWS credentials for the shared-services ECR+ id: ecr-credentials+ if: ${{ steps.ordered-release.outputs.tag != '' && matrix.registry == 'ecr' }}+ uses: aws-actions/configure-aws-credentials@ec61189d14ec14c8efccab744f656cffd0e33f37 # v6.1.0+ with:+ role-to-assume: ${{ secrets.AWS_ECR_SHARED_SERVICES_POSTHOG_MASTER_PUBLISH_IAM_ROLE }}+ aws-region: us-east-1++ - name: Login to the shared-services ECR+ id: ecr+ if: ${{ steps.ecr-credentials.outcome == 'success' }}+ uses: aws-actions/amazon-ecr-login@f2e9fc6c2b355c1890b65e6f6f0e2ac3e6e22f78 # v2.1.2+- name: Publish and reconcile ordered image aliases- if: ${{ steps.ordered-release.outputs.tag != '' }}+ if: ${{ steps.ordered-release.outputs.tag != '' && (matrix.registry == 'ghcr' || steps.ecr.outcome == 'success') }}timeout-minutes: 8shell: bashenv:DIGESTS: ${{ needs.build-images.outputs.digests }}ORDERED_ALIAS: ${{ steps.ordered-release.outputs.tag }}- REGISTRY: ghcr.io/posthog/posthog+ # The build pushed each digest to both registries, so each gets the alias.+ REGISTRY: ${{ matrix.registry == 'ghcr' && 'ghcr.io/posthog/posthog' || steps.ecr.outputs.registry }}# Same reconciliation as PostHog/shared-actions container-image-metadata: read# the alias before publishing, accept it when it already resolves to this# build, and never move it when it resolves elsewhere. Kargo caches the alias@@ -423,7 +445,7 @@ jobs:failures=$((failures + 1));;*)- echo "::error title=Ordered image alias read-back unavailable::${image}:${ORDERED_ALIAS} could not be read back from ghcr."+ echo "::error title=Ordered image alias read-back unavailable::${image}:${ORDERED_ALIAS} could not be read back from ${REGISTRY}."failures=$((failures + 1));;esacdiff --git a/.github/workflows/rust-smoke-test-build.yml b/.github/workflows/rust-smoke-test-build.ymlindex b2537eb04604..b06b99496e6b 100644--- a/.github/workflows/rust-smoke-test-build.yml+++ b/.github/workflows/rust-smoke-test-build.yml@@ -90,7 +90,10 @@ jobs:timeout-minutes: 30event-name: posthog-rust-smoke-test-image-buildextra-failure-props: '"pr": "${{ github.event.pull_request.number }}"'+ # PR builds go to the <image>-prs repositories, which expire pr-* tags after 2 days.+ ecr-repository-suffix: -prssecrets:+ AWS_ECR_SHARED_SERVICES_PUBLISH_IAM_ROLE: ${{ secrets.AWS_ECR_SHARED_SERVICES_POSTHOG_PRS_PUBLISH_IAM_ROLE }}POSTHOG_API_TOKEN: ${{ secrets.POSTHOG_API_TOKEN }}POSTHOG_DEVEX_PROJECT_API_TOKEN: ${{ secrets.POSTHOG_DEVEX_PROJECT_API_TOKEN }}permissions: