: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): publish an ordered release tag for the node image (#108080)
Daniel Marchukf41745082b05
diff --git a/.github/workflows/ci-nodejs-container.yml b/.github/workflows/ci-nodejs-container.ymlindex a40b624314a1..74d70c6bbd9a 100644--- a/.github/workflows/ci-nodejs-container.yml+++ b/.github/workflows/ci-nodejs-container.yml@@ -108,6 +108,8 @@ jobs:(github.event_name == 'push' && github.ref == 'refs/heads/master' && needs.changes.outputs.node_files == 'true' && github.repository_owner == 'PostHog' && vars.CD_DEPLOY_ENABLED == 'true')runs-on: depot-ubuntu-24.04timeout-minutes: 30+ outputs:+ image-digest: ${{ steps.build.outputs.digest }}permissions:id-token: write # allow issuing OIDC tokens for this workflow runcontents: read # allow reading the repo contents@@ -267,3 +269,172 @@ jobs:"labels": ${{ steps.labels.outputs.labels }},"timestamp": "${{ github.event.head_commit.timestamp }}"}++ ordered_image_alias:+ name: Publish ordered image alias+ needs: build+ # Kargo selects node releases by this tag, so a staged service on the node image can+ # take Freight from it. Mirrors the posthog_build alias job in container-images-cd.yml.+ # Best effort: a missing alias delays that service's Freight and never fails the deploy.+ if: ${{ needs.build.result == 'success' && github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository_owner == 'PostHog' && vars.CD_DEPLOY_ENABLED == 'true' && vars.ORDERED_IMAGE_ALIAS_PAUSED != 'true' }}+ runs-on: ubuntu-24.04+ timeout-minutes: 5+ continue-on-error: true+ permissions:+ id-token: write+ contents: read++ steps:+ - name: Check out+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2++ - name: Compute ordered release tag+ id: ordered-release+ timeout-minutes: 2+ shell: bash+ env:+ ORDERED_RELEASE_TAG_REGEX: ^r[0-9]{12}-[0-9a-f]{6}$+ run: |+ set -uo pipefail++ if [ "$(git rev-parse --is-shallow-repository)" = "true" ]; then+ fetch_status=0+ timeout --kill-after=10s 90s git fetch \+ --no-tags \+ --prune \+ --no-recurse-submodules \+ --unshallow \+ --filter=tree:0 \+ origin \+ "+${GITHUB_REF}:refs/remotes/origin/${GITHUB_REF_NAME}" || fetch_status=$?+ if [ "$fetch_status" -ne 0 ]; then+ echo "::warning title=Ordered release tag skipped::Source history could not be fetched (status $fetch_status)."+ exit 0+ fi+ fi++ if [ "$(git rev-parse --is-shallow-repository 2>/dev/null)" != "false" ]; then+ echo "::warning title=Ordered release tag skipped::Complete source history is unavailable."+ exit 0+ fi++ if ! head_revision="$(git rev-parse HEAD)" || [ "$head_revision" != "$GITHUB_SHA" ]; then+ echo "::warning title=Ordered release tag skipped::The checked-out revision does not match GITHUB_SHA."+ exit 0+ fi++ if ! position="$(git rev-list --first-parent --count "$GITHUB_SHA")"; then+ echo "::warning title=Ordered release tag skipped::The source position could not be computed."+ exit 0+ fi++ if ! [[ "$position" =~ ^[1-9][0-9]{0,11}$ ]]; then+ echo "::warning title=Ordered release tag skipped::The source position is out of range."+ exit 0+ fi++ if ! printf -v tag 'r%012d-%.6s' "$position" "$GITHUB_SHA"; then+ echo "::warning title=Ordered release tag skipped::The source position could not be formatted."+ exit 0+ fi++ if ! [[ "$tag" =~ $ORDERED_RELEASE_TAG_REGEX ]]; then+ echo "::warning title=Ordered release tag skipped::${tag} does not match the required format."+ exit 0+ fi++ echo "tag=${tag}" >> "$GITHUB_OUTPUT"++ - name: Warn when ordered image alias tag is unavailable+ if: ${{ steps.ordered-release.outputs.tag == '' }}+ shell: bash+ run: echo "::warning title=Ordered image alias tag unavailable::Ordered image alias publication was skipped because no ordered release tag was generated."++ - name: Set up Docker Buildx for ordered image alias+ if: ${{ steps.ordered-release.outputs.tag != '' }}+ uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0++ - name: Configure AWS credentials for ordered image alias+ if: ${{ steps.ordered-release.outputs.tag != '' }}+ 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 != '' }}+ id: ecr-login+ uses: aws-actions/amazon-ecr-login@f2e9fc6c2b355c1890b65e6f6f0e2ac3e6e22f78 # v2.1.2++ - name: Publish and read back ordered image alias+ if: ${{ steps.ordered-release.outputs.tag != '' }}+ timeout-minutes: 2+ shell: bash+ env:+ ECR_REGISTRY: ${{ steps.ecr-login.outputs.registry }}+ ECR_REPO: posthog-node+ EXPECTED_DIGEST: ${{ needs.build.outputs.image-digest }}+ ORDERED_ALIAS: ${{ steps.ordered-release.outputs.tag }}+ run: |+ set -uo pipefail++ if [ -z "$EXPECTED_DIGEST" ]; then+ echo "::warning title=Ordered image alias source digest unavailable::Ordered image alias publication was skipped because no image digest was resolved."+ exit 0+ fi++ if [ -z "$ECR_REGISTRY" ]; then+ echo "::warning title=Ordered image alias destination unavailable::Ordered image alias publication was skipped because the ECR registry resolved empty."+ exit 0+ fi++ SOURCE_IMAGE="${ECR_REGISTRY}/${ECR_REPO}@${EXPECTED_DIGEST}"+ TARGET_IMAGE="${ECR_REGISTRY}/${ECR_REPO}:${ORDERED_ALIAS}"++ publication_status=0+ timeout --kill-after=5s 40s docker buildx imagetools create \+ --prefer-index=false \+ --tag "$TARGET_IMAGE" \+ "$SOURCE_IMAGE" || publication_status=$?+ if [ "$publication_status" -ne 0 ]; then+ echo "::warning::Ordered alias publication exited with status $publication_status"+ fi++ readback_status=0+ resolved_digest="$(timeout --kill-after=5s 40s aws ecr batch-get-image \+ --repository-name "$ECR_REPO" \+ --image-ids imageTag="$ORDERED_ALIAS" \+ --accepted-media-types \+ "application/vnd.oci.image.index.v1+json" \+ "application/vnd.docker.distribution.manifest.list.v2+json" \+ "application/vnd.oci.image.manifest.v1+json" \+ "application/vnd.docker.distribution.manifest.v2+json" \+ --query 'images[0].imageId.imageDigest' \+ --output text)" || readback_status=$?++ if [ "$readback_status" -ne 0 ]; then+ result=unknown+ elif [ "$resolved_digest" = "None" ]; then+ result=absent+ elif [[ "$resolved_digest" =~ ^sha256:[0-9a-f]{64}$ ]] && [ "$resolved_digest" = "$EXPECTED_DIGEST" ]; then+ result=present-at-expected-digest+ elif [[ "$resolved_digest" =~ ^sha256:[0-9a-f]{64}$ ]]; then+ result=integrity-mismatch+ else+ result=unknown+ fi++ case "$result" in+ present-at-expected-digest)+ echo "::notice title=Ordered image alias present::The ordered image alias resolves to the expected image digest."+ ;;+ absent)+ echo "::warning title=Ordered image alias absent::The ordered image alias is absent after publication."+ ;;+ integrity-mismatch)+ echo "::error title=Ordered image alias integrity mismatch::The ordered image alias resolves to a different image digest."+ ;;+ unknown)+ echo "::error title=Ordered image alias read-back unavailable::The ordered image alias could not be read back from ECR."+ ;;+ esac