: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): migrate remaining CD image workflows off the shared ECR role (#75192)
Tom Piccirellob258ee3529ca
diff --git a/.github/workflows/cd-agent-proxy-image.yml b/.github/workflows/cd-agent-proxy-image.ymlindex 0efa9c1d2853..21c7e2ba4517 100644--- a/.github/workflows/cd-agent-proxy-image.yml+++ b/.github/workflows/cd-agent-proxy-image.yml@@ -38,7 +38,10 @@ jobs:uses: ./.github/actions/docker-metawith:image-name: posthog-agent-proxy- aws-role-to-assume: ${{ secrets.AWS_ECR_PUBLISH_IAM_ROLE }}+ # Publishes only from the default branch — assume the role and touch ECR only there+ # (a non-default-branch workflow_dispatch builds nothing to push).+ aws-role-to-assume: ${{ vars.AWS_ECR_POSTHOG_MASTER_PUBLISH_IAM_ROLE }}+ push-to-ecr: ${{ github.ref == 'refs/heads/master' }}github-token: ${{ secrets.GITHUB_TOKEN }}dockerhub-username: ${{ secrets.DOCKERHUB_USER }}dockerhub-password: ${{ secrets.DOCKERHUB_TOKEN }}diff --git a/.github/workflows/cd-llm-analytics-image.yml b/.github/workflows/cd-llm-analytics-image.ymlindex 0fd4ea4b4e8f..10ea57346c7a 100644--- a/.github/workflows/cd-llm-analytics-image.yml+++ b/.github/workflows/cd-llm-analytics-image.yml@@ -55,7 +55,24 @@ jobs:id-token: writecontents: read+ # ECR repo + role resolved once, keyed on the branch, so the configure-aws role and the+ # tags target can't drift: default branch → posthog-llm-analytics via the default-branch+ # role; a labeled PR → posthog-llm-analytics-prs via the any-branch prs role.+ env:+ ECR_IMAGE: ${{ github.ref == 'refs/heads/master' && 'posthog-llm-analytics' || 'posthog-llm-analytics-prs' }}+ ECR_ROLE: ${{ github.ref == 'refs/heads/master' && vars.AWS_ECR_POSTHOG_MASTER_PUBLISH_IAM_ROLE || vars.AWS_ECR_POSTHOG_PRS_PUBLISH_IAM_ROLE }}+steps:+ - name: Assert default-branch publish role is configured+ if: github.ref == 'refs/heads/master'+ env:+ DEFAULT_BRANCH_ROLE: ${{ vars.AWS_ECR_POSTHOG_MASTER_PUBLISH_IAM_ROLE }}+ run: |+ if [[ -z "$DEFAULT_BRANCH_ROLE" ]]; then+ echo "::error::AWS_ECR_POSTHOG_MASTER_PUBLISH_IAM_ROLE is not set — refusing to fall back to the PRS role on the default branch."+ exit 1+ fi+- name: Check outuses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2with:@@ -73,7 +90,7 @@ jobs:- name: Configure AWS credentialsuses: aws-actions/configure-aws-credentials@ec61189d14ec14c8efccab744f656cffd0e33f37 # v6.1.0with:- role-to-assume: ${{ secrets.AWS_ECR_PUBLISH_IAM_ROLE }}+ role-to-assume: ${{ env.ECR_ROLE }}aws-region: us-east-1- name: Login to Amazon ECR@@ -88,7 +105,7 @@ jobs:file: ./Dockerfile.llm-analyticsbuildx-fallback: falsepush: ${{ github.event_name == 'pull_request' || vars.CD_DEPLOY_ENABLED == 'true' }}- tags: ${{ github.ref == 'refs/heads/master' && format('{0}/posthog-llm-analytics:master,{0}/posthog-llm-analytics:{1}', steps.aws-ecr.outputs.registry, github.sha) || format('{0}/posthog-llm-analytics:{1}', steps.aws-ecr.outputs.registry, github.sha) }}+ tags: ${{ github.ref == 'refs/heads/master' && format('{0}/{1}:master,{0}/{1}:{2}', steps.aws-ecr.outputs.registry, env.ECR_IMAGE, github.sha) || format('{0}/{1}:{2}', steps.aws-ecr.outputs.registry, env.ECR_IMAGE, github.sha) }}platforms: linux/arm64,linux/amd64build-args: COMMIT_HASH=${{ github.sha }}diff --git a/.github/workflows/cd-mcp-image.yml b/.github/workflows/cd-mcp-image.ymlindex 3964327778a6..1da81f9a14d0 100644--- a/.github/workflows/cd-mcp-image.yml+++ b/.github/workflows/cd-mcp-image.yml@@ -52,7 +52,10 @@ jobs:uses: ./.github/actions/docker-metawith:image-name: posthog-mcp- aws-role-to-assume: ${{ secrets.AWS_ECR_PUBLISH_IAM_ROLE }}+ # Publishes only from the default branch — assume the role and touch ECR only there;+ # labeled PRs still build (push=false) without assuming it.+ aws-role-to-assume: ${{ vars.AWS_ECR_POSTHOG_MASTER_PUBLISH_IAM_ROLE }}+ push-to-ecr: ${{ github.ref == 'refs/heads/master' }}github-token: ${{ secrets.GITHUB_TOKEN }}dockerhub-username: ${{ secrets.DOCKERHUB_USER }}dockerhub-password: ${{ secrets.DOCKERHUB_TOKEN }}diff --git a/.github/workflows/llm-gateway-cd.yml b/.github/workflows/llm-gateway-cd.ymlindex be6bc4d179b6..a895b597b637 100644--- a/.github/workflows/llm-gateway-cd.yml+++ b/.github/workflows/llm-gateway-cd.yml@@ -37,7 +37,10 @@ jobs:uses: ./.github/actions/docker-metawith:image-name: llm-gateway- aws-role-to-assume: ${{ secrets.AWS_ECR_PUBLISH_IAM_ROLE }}+ # Publishes only from the default branch — assume the role and touch ECR only there+ # (a non-default-branch workflow_dispatch builds nothing to push).+ aws-role-to-assume: ${{ vars.AWS_ECR_POSTHOG_MASTER_PUBLISH_IAM_ROLE }}+ push-to-ecr: ${{ github.ref == 'refs/heads/master' }}github-token: ${{ secrets.GITHUB_TOKEN }}dockerhub-username: ${{ secrets.DOCKERHUB_USER }}dockerhub-password: ${{ secrets.DOCKERHUB_TOKEN }}