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): publish the credentials-service ordered image alias to ECR too (#117262)

Georges-Antoine Assie97378f58a17
diff --git a/.github/workflows/cd-credentials-service-image.yml b/.github/workflows/cd-credentials-service-image.yml
index 7949a64ef5d8..c733ab716bc8 100644
--- a/.github/workflows/cd-credentials-service-image.yml
+++ b/.github/workflows/cd-credentials-service-image.yml
@@ -76,6 +76,7 @@ jobs:
permissions:
contents: read
packages: write
+ id-token: write
steps:
- name: Check out
@@ -155,12 +156,27 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
+ - name: Configure AWS credentials for ordered image alias
+ if: ${{ steps.ordered-release.outputs.tag != '' }}
+ continue-on-error: true
+ uses: aws-actions/configure-aws-credentials@ec61189d14ec14c8efccab744f656cffd0e33f37 # v6.1.0
+ with:
+ role-to-assume: ${{ vars.AWS_ECR_POSTHOG_MASTER_PUBLISH_IAM_ROLE }}
+ aws-region: us-east-1
+
+ - name: Log in to Amazon ECR for ordered image alias
+ if: ${{ steps.ordered-release.outputs.tag != '' }}
+ continue-on-error: true
+ id: ecr-login
+ uses: aws-actions/amazon-ecr-login@f2e9fc6c2b355c1890b65e6f6f0e2ac3e6e22f78 # v2.1.2
+
- name: Publish and reconcile ordered image alias
if: ${{ steps.ordered-release.outputs.tag != '' }}
- timeout-minutes: 5
+ timeout-minutes: 8
shell: bash
env:
- IMAGE: ghcr.io/posthog/posthog-credentials-service
+ GHCR_IMAGE: ghcr.io/posthog/posthog-credentials-service
+ ECR_REGISTRY: ${{ steps.ecr-login.outputs.registry }}
DIGEST: ${{ needs.build.outputs.sha }}
ORDERED_ALIAS: ${{ steps.ordered-release.outputs.tag }}
# Read the alias before publishing, accept it when it already resolves to this
@@ -194,37 +210,49 @@ jobs:
fi
}
- SOURCE_IMAGE="${IMAGE}@${DIGEST}"
- TARGET_IMAGE="${IMAGE}:${ORDERED_ALIAS}"
-
- state="$(classify_alias)"
- if [ "$state" = "absent" ]; then
- # --prefer-index=false re-tags the existing index by digest, so the
- # alias resolves to the same digest and keeps its annotations.
- timeout --kill-after=10s 35s docker buildx imagetools create \
- --prefer-index=false \
- --tag "$TARGET_IMAGE" \
- "$SOURCE_IMAGE" >&2 || echo "::warning::Alias publication client exited $?"
+ publish_alias() {
+ SOURCE_IMAGE="${1}@${DIGEST}"
+ TARGET_IMAGE="${1}:${ORDERED_ALIAS}"
+
state="$(classify_alias)"
- fi
+ if [ "$state" = "absent" ]; then
+ # --prefer-index=false re-tags the existing index by digest, so the
+ # alias resolves to the same digest and keeps its annotations.
+ timeout --kill-after=10s 35s docker buildx imagetools create \
+ --prefer-index=false \
+ --tag "$TARGET_IMAGE" \
+ "$SOURCE_IMAGE" >&2 || echo "::warning::Alias publication client exited $?"
+ state="$(classify_alias)"
+ fi
- case "$state" in
- present-at-expected-digest)
- echo "::notice title=Ordered image alias present::${TARGET_IMAGE} resolves to ${DIGEST}."
- ;;
- integrity-mismatch)
- echo "::error title=Ordered image alias integrity mismatch::${TARGET_IMAGE} resolves to a different digest; left untouched."
- exit 1
- ;;
- absent)
- echo "::warning title=Ordered image alias absent::${TARGET_IMAGE} is absent after publication."
- exit 1
- ;;
- *)
- echo "::error title=Ordered image alias read-back unavailable::${TARGET_IMAGE} could not be read back from ghcr."
- exit 1
- ;;
- esac
+ case "$state" in
+ present-at-expected-digest)
+ echo "::notice title=Ordered image alias present::${TARGET_IMAGE} resolves to ${DIGEST}."
+ ;;
+ integrity-mismatch)
+ echo "::error title=Ordered image alias integrity mismatch::${TARGET_IMAGE} resolves to a different digest; left untouched."
+ return 1
+ ;;
+ absent)
+ echo "::warning title=Ordered image alias absent::${TARGET_IMAGE} is absent after publication."
+ return 1
+ ;;
+ *)
+ echo "::error title=Ordered image alias read-back unavailable::${TARGET_IMAGE} could not be read back."
+ return 1
+ ;;
+ esac
+ }
+
+ status=0
+ publish_alias "$GHCR_IMAGE" || status=1
+ if [ -n "$ECR_REGISTRY" ]; then
+ publish_alias "${ECR_REGISTRY}/posthog-credentials-service" || status=1
+ else
+ echo "::warning title=Ordered image alias destination unavailable::The ECR registry resolved empty, so the ECR alias was skipped."
+ status=1
+ fi
+ exit "$status"
deploy:
name: Trigger credentials-service deployment