From 30e1270fe9e6fc7560c0aea3ebd9d928f217b3e4 Mon Sep 17 00:00:00 2001 From: Theodore Li Date: Thu, 16 Jul 2026 18:33:16 -0700 Subject: [PATCH 01/10] feat(ci): promote Trigger.dev tasks in lockstep with the ECS traffic cutover --- .github/scripts/wait-for-ecs-cutover.sh | 105 +++++++++ .github/workflows/ci.yml | 287 ++++++++++++++++++++++++ 2 files changed, 392 insertions(+) create mode 100755 .github/scripts/wait-for-ecs-cutover.sh diff --git a/.github/scripts/wait-for-ecs-cutover.sh b/.github/scripts/wait-for-ecs-cutover.sh new file mode 100755 index 00000000000..4ec90125804 --- /dev/null +++ b/.github/scripts/wait-for-ecs-cutover.sh @@ -0,0 +1,105 @@ +#!/usr/bin/env bash +# Waits for the ECS blue/green deploy triggered by a specific app image push to +# reach its traffic cutover (CodeDeploy AllowTraffic == Succeeded), then exits 0. +# +# ECR app images use a floating tag (latest/staging) with no git SHA, so the +# only durable key linking this CI push to its ECS deploy is the image DIGEST. +# Correlation: image digest -> CodePipeline execution (AppEcrImage revision) -> +# Deploy action externalExecutionId (== CodeDeploy deployment id) -> AllowTraffic. +# +# Usage: wait-for-ecs-cutover.sh +# Requires: awscli v2, configured credentials with codedeploy + codepipeline read. +set -euo pipefail + +PIPELINE="${1:?pipeline name required}" +DIGEST="${2:?image digest required}" + +POLL_INTERVAL="${POLL_INTERVAL:-15}" +# 70 min covers a prod deploy whose Deploy stage is queued behind a prior +# deploy's ~50-min termination bake before its own traffic shift begins. +OVERALL_TIMEOUT="${OVERALL_TIMEOUT:-4200}" + +deadline=$(( $(date +%s) + OVERALL_TIMEOUT )) +remaining() { echo $(( deadline - $(date +%s) )); } +log() { echo "[wait-for-ecs-cutover] $*"; } +fail_if_expired() { + if [ "$(remaining)" -le 0 ]; then + log "ERROR: timed out after ${OVERALL_TIMEOUT}s waiting for: $1" + exit 1 + fi +} + +log "Pipeline: $PIPELINE" +log "Target app image digest: $DIGEST" + +# Phase A: find the pipeline execution whose ECR source revision matches our +# digest. --max-items bounds the fetch (the CLI otherwise auto-paginates the whole +# execution history); our push is the newest execution, so it's on the first page. +# The revisionId match is done server-side via JMESPath; grep isolates the UUID +# from any trailing pagination-token line in text output. +EXECUTION_ID="" +while [ -z "$EXECUTION_ID" ]; do + fail_if_expired "pipeline execution matching digest" + EXECUTION_ID=$(aws codepipeline list-pipeline-executions \ + --pipeline-name "$PIPELINE" --max-items 30 \ + --query "pipelineExecutionSummaries[?sourceRevisions[?actionName=='ECR_Source' && revisionId=='$DIGEST']].pipelineExecutionId" \ + --output text 2>/dev/null | tr '\t ' '\n\n' | grep -Em1 '^[0-9a-f-]{36}$' || true) + if [ -z "$EXECUTION_ID" ]; then + log "No matching pipeline execution yet; retry in ${POLL_INTERVAL}s (remaining $(remaining)s)" + sleep "$POLL_INTERVAL" + fi +done +log "Matched pipeline execution: $EXECUTION_ID" + +# Phase B: resolve the CodeDeploy deployment id from the Deploy action. This may +# stay empty for a while if the Deploy stage is queued behind a prior deploy. +DEPLOYMENT_ID="" +while [ -z "$DEPLOYMENT_ID" ] || [ "$DEPLOYMENT_ID" = "None" ]; do + fail_if_expired "CodeDeploy deployment id (Deploy stage may be queued behind a prior deploy's bake)" + status=$(aws codepipeline get-pipeline-execution \ + --pipeline-name "$PIPELINE" --pipeline-execution-id "$EXECUTION_ID" \ + --query 'pipelineExecution.status' --output text 2>/dev/null || true) + case "$status" in + Failed|Stopped|Superseded) + log "ERROR: pipeline execution $EXECUTION_ID ended in status $status before deploy" + exit 1 + ;; + esac + DEPLOYMENT_ID=$(aws codepipeline list-action-executions \ + --pipeline-name "$PIPELINE" \ + --filter pipelineExecutionId="$EXECUTION_ID" \ + --query "actionExecutionDetails[?stageName=='Deploy'].output.executionResult.externalExecutionId | [0]" \ + --output text 2>/dev/null || true) + if [ -z "$DEPLOYMENT_ID" ] || [ "$DEPLOYMENT_ID" = "None" ]; then + log "Deploy stage not started yet (pipeline status: $status); retry in ${POLL_INTERVAL}s (remaining $(remaining)s)" + sleep "$POLL_INTERVAL" + fi +done +log "CodeDeploy deployment: $DEPLOYMENT_ID" + +# Phase C: wait for the traffic cutover (AllowTraffic lifecycle event Succeeded). +while true; do + fail_if_expired "AllowTraffic (traffic cutover)" + dstatus=$(aws deploy get-deployment --deployment-id "$DEPLOYMENT_ID" \ + --query 'deploymentInfo.status' --output text 2>/dev/null || true) + case "$dstatus" in + Failed|Stopped) + log "ERROR: CodeDeploy deployment $DEPLOYMENT_ID ended in status $dstatus; not promoting" + exit 1 + ;; + esac + target_id=$(aws deploy list-deployment-targets --deployment-id "$DEPLOYMENT_ID" \ + --query 'targetIds[0]' --output text 2>/dev/null || true) + at_status="" + if [ -n "$target_id" ] && [ "$target_id" != "None" ]; then + at_status=$(aws deploy get-deployment-target --deployment-id "$DEPLOYMENT_ID" --target-id "$target_id" \ + --query "deploymentTarget.ecsTarget.lifecycleEvents[?lifecycleEventName=='AllowTraffic'].status | [0]" \ + --output text 2>/dev/null || true) + if [ "$at_status" = "Succeeded" ]; then + log "Traffic cutover complete (AllowTraffic Succeeded) for $DEPLOYMENT_ID" + exit 0 + fi + fi + log "Deployment $DEPLOYMENT_ID status=$dstatus AllowTraffic=${at_status:-pending}; wait ${POLL_INTERVAL}s (remaining $(remaining)s)" + sleep "$POLL_INTERVAL" +done diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ca2901c7871..9571ac30c5e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -182,6 +182,118 @@ jobs: fi bunx trigger.dev@4.4.3 deploy --env preview --branch dev-sim + # Staging: build & upload the Trigger.dev task version WITHOUT promoting it + # (--skip-promotion). New runs keep executing the old version until the promote + # job flips it at the ECS traffic cutover, so this deploy carries zero + # app<->task skew and runs in parallel with the image build. The captured + # version output is consumed by promote-trigger-staging. + deploy-trigger-staging: + name: Deploy Trigger.dev (Staging) + needs: [migrate] + if: github.event_name == 'push' && github.ref == 'refs/heads/staging' + runs-on: blacksmith-4vcpu-ubuntu-2404 + timeout-minutes: 15 + outputs: + version: ${{ steps.deploy.outputs.version }} + steps: + - name: Checkout code + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 + + - name: Setup Bun + uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2 + with: + bun-version: 1.3.13 + + - name: Cache Bun dependencies + uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5 + with: + path: | + ~/.bun/install/cache + node_modules + **/node_modules + key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }} + restore-keys: | + ${{ runner.os }}-bun- + + - name: Install dependencies + run: bun install --frozen-lockfile + + - name: Deploy to Trigger.dev (skip promotion) + id: deploy + working-directory: ./apps/sim + env: + TRIGGER_ACCESS_TOKEN: ${{ secrets.TRIGGER_ACCESS_TOKEN }} + TRIGGER_PROJECT_ID: ${{ secrets.TRIGGER_PROJECT_ID }} + run: | + set -eo pipefail + if [ -z "$TRIGGER_ACCESS_TOKEN" ] || [ -z "$TRIGGER_PROJECT_ID" ]; then + echo "ERROR: TRIGGER_ACCESS_TOKEN and TRIGGER_PROJECT_ID repo secrets must both be set" >&2 + exit 1 + fi + bunx trigger.dev@4.4.3 deploy --env staging --skip-promotion 2>&1 | tee deploy.log + # Extract the deployed version (e.g. 20260715.2) tied to THIS invocation. + VERSION=$(sed -E 's/\x1b\[[0-9;]*m//g' deploy.log | grep -oE '20[0-9]{6}\.[0-9]+' | tail -n1 || true) + if [ -z "$VERSION" ]; then + echo "ERROR: could not parse deployed version from deploy output" >&2 + exit 1 + fi + echo "Captured deployed version: $VERSION" + echo "version=$VERSION" >> "$GITHUB_OUTPUT" + + # Production: same skip-promotion deploy as staging, for the prod environment. + deploy-trigger-production: + name: Deploy Trigger.dev (Production) + needs: [migrate] + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + runs-on: blacksmith-4vcpu-ubuntu-2404 + timeout-minutes: 15 + outputs: + version: ${{ steps.deploy.outputs.version }} + steps: + - name: Checkout code + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 + + - name: Setup Bun + uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2 + with: + bun-version: 1.3.13 + + - name: Cache Bun dependencies + uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5 + with: + path: | + ~/.bun/install/cache + node_modules + **/node_modules + key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }} + restore-keys: | + ${{ runner.os }}-bun- + + - name: Install dependencies + run: bun install --frozen-lockfile + + - name: Deploy to Trigger.dev (skip promotion) + id: deploy + working-directory: ./apps/sim + env: + TRIGGER_ACCESS_TOKEN: ${{ secrets.TRIGGER_ACCESS_TOKEN }} + TRIGGER_PROJECT_ID: ${{ secrets.TRIGGER_PROJECT_ID }} + run: | + set -eo pipefail + if [ -z "$TRIGGER_ACCESS_TOKEN" ] || [ -z "$TRIGGER_PROJECT_ID" ]; then + echo "ERROR: TRIGGER_ACCESS_TOKEN and TRIGGER_PROJECT_ID repo secrets must both be set" >&2 + exit 1 + fi + bunx trigger.dev@4.4.3 deploy --env prod --skip-promotion 2>&1 | tee deploy.log + # Extract the deployed version (e.g. 20260715.2) tied to THIS invocation. + VERSION=$(sed -E 's/\x1b\[[0-9;]*m//g' deploy.log | grep -oE '20[0-9]{6}\.[0-9]+' | tail -n1 || true) + if [ -z "$VERSION" ]; then + echo "ERROR: could not parse deployed version from deploy output" >&2 + exit 1 + fi + echo "Captured deployed version: $VERSION" + echo "version=$VERSION" >> "$GITHUB_OUTPUT" + # Main/staging: build AMD64 images and push sha-tagged images to ECR + GHCR. # Runs in parallel with tests — only immutable sha tags are pushed here, and # the CodePipeline EventBridge triggers filter on exactly the @@ -270,6 +382,7 @@ jobs: echo "tags=${TAGS}" >> $GITHUB_OUTPUT - name: Build and push images + id: build uses: useblacksmith/build-push-action@fb9e3e6a9299c78462bfadd0d93352c316adc9b8 # v2 with: context: . @@ -280,6 +393,25 @@ jobs: provenance: false sbom: false + # Publish the app image digest so promote-trigger-* can correlate this push + # to its ECS CodePipeline execution. promote-images retags this same sha + # image to latest/staging (preserving the digest), so the pipeline's ECR + # source revision equals this digest — the only durable key (the deploy tag + # is floating). App leg only. + - name: Publish app image digest + if: matrix.ecr_repo_secret == 'ECR_APP' + run: | + mkdir -p digest + echo "${{ steps.build.outputs.digest }}" > digest/app-image-digest.txt + + - name: Upload app image digest + if: matrix.ecr_repo_secret == 'ECR_APP' + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: app-image-digest + path: digest/app-image-digest.txt + retention-days: 1 + # Promote the sha-tagged ECR images to the deploy tags once tests and # migrations pass. Pushing the ECR latest/staging tag is what triggers # CodePipeline, so this seconds-long manifest retag is the deploy gate — @@ -297,6 +429,11 @@ jobs: permissions: contents: read id-token: write + outputs: + # Whether the deploy tag was actually moved (false on a stale-run guard + # skip). promote-trigger-* keys off this so tasks are never promoted when + # the app itself wasn't. + promoted: ${{ steps.guard.outputs.fresh }} steps: - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@e7f100cf4c008499ea8adda475de1042d6975c7b # v6 @@ -356,6 +493,156 @@ jobs: "${REGISTRY}/${repo}:${{ github.sha }}" done + # Staging: promote the skip-promoted Trigger.dev version at the exact moment the + # ECS app deploy shifts traffic (CodeDeploy AllowTraffic), so tasks and app cut + # over in lockstep. The promote-images retag above is what triggers the ECS + # pipeline; this job polls it (via the app image digest) and promotes at cutover. + # Skipped when promote-images skipped the tag move (stale run) — tasks then + # correctly stay on the old version. If the app deploy fails or never cuts over, + # promote never fires and this job fails visibly. + promote-trigger-staging: + name: Promote Trigger.dev (Staging) + needs: [promote-images, deploy-trigger-staging] + if: >- + github.event_name == 'push' && github.ref == 'refs/heads/staging' && + needs.promote-images.outputs.promoted == 'true' + runs-on: blacksmith-4vcpu-ubuntu-2404 + timeout-minutes: 75 + permissions: + contents: read + id-token: write + steps: + - name: Checkout code + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 + + - name: Setup Bun + uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2 + with: + bun-version: 1.3.13 + + - name: Cache Bun dependencies + uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5 + with: + path: | + ~/.bun/install/cache + node_modules + **/node_modules + key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }} + restore-keys: | + ${{ runner.os }}-bun- + + - name: Install dependencies + run: bun install --frozen-lockfile + + - name: Download app image digest + uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 + with: + name: app-image-digest + path: digest + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@e7f100cf4c008499ea8adda475de1042d6975c7b # v6 + with: + role-to-assume: ${{ secrets.STAGING_AWS_ROLE_TO_ASSUME }} + aws-region: ${{ secrets.STAGING_AWS_REGION }} + + - name: Wait for ECS traffic cutover + run: | + set -eo pipefail + DIGEST=$(cat digest/app-image-digest.txt) + bash .github/scripts/wait-for-ecs-cutover.sh sim-staging-us-east-1-app-deployment "$DIGEST" + + - name: Promote Trigger.dev version + working-directory: ./apps/sim + env: + TRIGGER_ACCESS_TOKEN: ${{ secrets.TRIGGER_ACCESS_TOKEN }} + TRIGGER_PROJECT_ID: ${{ secrets.TRIGGER_PROJECT_ID }} + VERSION: ${{ needs.deploy-trigger-staging.outputs.version }} + run: | + set -eo pipefail + if [ -z "$TRIGGER_ACCESS_TOKEN" ] || [ -z "$TRIGGER_PROJECT_ID" ]; then + echo "ERROR: TRIGGER_ACCESS_TOKEN and TRIGGER_PROJECT_ID repo secrets must both be set" >&2 + exit 1 + fi + if [ -z "$VERSION" ]; then + echo "ERROR: no deployed version passed from deploy-trigger-staging" >&2 + exit 1 + fi + echo "Promoting Trigger.dev version $VERSION (staging) at ECS cutover" + bunx trigger.dev@4.4.3 promote "$VERSION" --env staging + + # Production: same lockstep promotion as staging, for the prod environment. + promote-trigger-production: + name: Promote Trigger.dev (Production) + needs: [promote-images, deploy-trigger-production] + if: >- + github.event_name == 'push' && github.ref == 'refs/heads/main' && + needs.promote-images.outputs.promoted == 'true' + runs-on: blacksmith-4vcpu-ubuntu-2404 + timeout-minutes: 75 + permissions: + contents: read + id-token: write + steps: + - name: Checkout code + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 + + - name: Setup Bun + uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2 + with: + bun-version: 1.3.13 + + - name: Cache Bun dependencies + uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5 + with: + path: | + ~/.bun/install/cache + node_modules + **/node_modules + key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }} + restore-keys: | + ${{ runner.os }}-bun- + + - name: Install dependencies + run: bun install --frozen-lockfile + + - name: Download app image digest + uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 + with: + name: app-image-digest + path: digest + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@e7f100cf4c008499ea8adda475de1042d6975c7b # v6 + with: + role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + aws-region: ${{ secrets.AWS_REGION }} + + - name: Wait for ECS traffic cutover + run: | + set -eo pipefail + DIGEST=$(cat digest/app-image-digest.txt) + bash .github/scripts/wait-for-ecs-cutover.sh sim-production-us-east-1-app-deployment "$DIGEST" + + - name: Promote Trigger.dev version + working-directory: ./apps/sim + env: + TRIGGER_ACCESS_TOKEN: ${{ secrets.TRIGGER_ACCESS_TOKEN }} + TRIGGER_PROJECT_ID: ${{ secrets.TRIGGER_PROJECT_ID }} + VERSION: ${{ needs.deploy-trigger-production.outputs.version }} + run: | + set -eo pipefail + if [ -z "$TRIGGER_ACCESS_TOKEN" ] || [ -z "$TRIGGER_PROJECT_ID" ]; then + echo "ERROR: TRIGGER_ACCESS_TOKEN and TRIGGER_PROJECT_ID repo secrets must both be set" >&2 + exit 1 + fi + if [ -z "$VERSION" ]; then + echo "ERROR: no deployed version passed from deploy-trigger-production" >&2 + exit 1 + fi + echo "Promoting Trigger.dev version $VERSION (production) at ECS cutover" + bunx trigger.dev@4.4.3 promote "$VERSION" --env prod + # Build ARM64 images for GHCR (main branch only, runs in parallel with # tests). Pushes only the immutable sha tag — latest-arm64/version-arm64 # are applied by create-ghcr-manifests after the gate, so a failing run From b207a52e7c1c446e69a5ce78a15f2ee566a36dc7 Mon Sep 17 00:00:00 2001 From: Theodore Li Date: Sun, 19 Jul 2026 12:17:49 -0700 Subject: [PATCH 02/10] =?UTF-8?q?fix(ci):=20harden=20Trigger.dev=20cutover?= =?UTF-8?q?=20gate=20=E2=80=94=20reject=20stale=20executions,=20verify=20a?= =?UTF-8?q?ll=20ECS=20targets?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/scripts/wait-for-ecs-cutover.sh | 93 +++++++---- .github/workflows/ci.yml | 195 ++++++------------------ 2 files changed, 112 insertions(+), 176 deletions(-) diff --git a/.github/scripts/wait-for-ecs-cutover.sh b/.github/scripts/wait-for-ecs-cutover.sh index 4ec90125804..f7ea7970567 100755 --- a/.github/scripts/wait-for-ecs-cutover.sh +++ b/.github/scripts/wait-for-ecs-cutover.sh @@ -1,23 +1,32 @@ #!/usr/bin/env bash # Waits for the ECS blue/green deploy triggered by a specific app image push to -# reach its traffic cutover (CodeDeploy AllowTraffic == Succeeded), then exits 0. +# reach its traffic cutover (CodeDeploy AllowTraffic == Succeeded on every ECS +# target), then exits 0. # # ECR app images use a floating tag (latest/staging) with no git SHA, so the # only durable key linking this CI push to its ECS deploy is the image DIGEST. -# Correlation: image digest -> CodePipeline execution (AppEcrImage revision) -> +# Correlation: image digest -> CodePipeline execution (ECR_Source revision) -> # Deploy action externalExecutionId (== CodeDeploy deployment id) -> AllowTraffic. # -# Usage: wait-for-ecs-cutover.sh -# Requires: awscli v2, configured credentials with codedeploy + codepipeline read. +# The digest alone is ambiguous: a prior run with the same image could match an +# older, already-cutover execution and promote too early. SINCE_EPOCH (the time +# the deploy tag was retagged, i.e. when THIS push's pipeline was triggered) +# disambiguates — only an execution that started at/after the retag is ours. +# +# Usage: wait-for-ecs-cutover.sh +# Requires: awscli v2, python3, credentials with codedeploy + codepipeline read. set -euo pipefail PIPELINE="${1:?pipeline name required}" DIGEST="${2:?image digest required}" +SINCE_EPOCH="${3:?since-epoch (retag time) required}" POLL_INTERVAL="${POLL_INTERVAL:-15}" # 70 min covers a prod deploy whose Deploy stage is queued behind a prior # deploy's ~50-min termination bake before its own traffic shift begins. OVERALL_TIMEOUT="${OVERALL_TIMEOUT:-4200}" +# Tolerate minor clock skew between the runner (retag time) and CodePipeline. +SINCE_SKEW="${SINCE_SKEW:-120}" deadline=$(( $(date +%s) + OVERALL_TIMEOUT )) remaining() { echo $(( deadline - $(date +%s) )); } @@ -31,21 +40,44 @@ fail_if_expired() { log "Pipeline: $PIPELINE" log "Target app image digest: $DIGEST" +log "Requiring execution started at/after epoch $SINCE_EPOCH (minus ${SINCE_SKEW}s skew)" -# Phase A: find the pipeline execution whose ECR source revision matches our -# digest. --max-items bounds the fetch (the CLI otherwise auto-paginates the whole -# execution history); our push is the newest execution, so it's on the first page. -# The revisionId match is done server-side via JMESPath; grep isolates the UUID -# from any trailing pagination-token line in text output. +# Phase A: find the newest pipeline execution whose ECR source revision matches +# our digest AND that started at/after the retag. The since filter rejects a +# stale historical execution reusing the same digest. --max-items bounds the +# fetch (the CLI otherwise auto-paginates the whole history). EXECUTION_ID="" while [ -z "$EXECUTION_ID" ]; do - fail_if_expired "pipeline execution matching digest" - EXECUTION_ID=$(aws codepipeline list-pipeline-executions \ + fail_if_expired "pipeline execution matching digest since retag" + matches=$(aws codepipeline list-pipeline-executions \ --pipeline-name "$PIPELINE" --max-items 30 \ - --query "pipelineExecutionSummaries[?sourceRevisions[?actionName=='ECR_Source' && revisionId=='$DIGEST']].pipelineExecutionId" \ - --output text 2>/dev/null | tr '\t ' '\n\n' | grep -Em1 '^[0-9a-f-]{36}$' || true) + --query "pipelineExecutionSummaries[?sourceRevisions[?actionName=='ECR_Source' && revisionId=='$DIGEST']].[startTime, pipelineExecutionId]" \ + --output text 2>/dev/null || true) + EXECUTION_ID=$(printf '%s\n' "$matches" | SINCE="$SINCE_EPOCH" SKEW="$SINCE_SKEW" python3 -c ' +import sys, os, datetime +since = float(os.environ["SINCE"]) - float(os.environ["SKEW"]) +best_epoch = None +best_id = None +for line in sys.stdin: + parts = line.rstrip("\n").split("\t") + if len(parts) < 2: + continue + ts, eid = parts[0].strip(), parts[1].strip() + if not ts or not eid or "-" not in eid: + continue + try: + epoch = float(ts) + except ValueError: + try: + epoch = datetime.datetime.fromisoformat(ts.replace("Z", "+00:00")).timestamp() + except ValueError: + continue + if epoch >= since and (best_epoch is None or epoch > best_epoch): + best_epoch, best_id = epoch, eid +print(best_id or "") +' 2>/dev/null || true) if [ -z "$EXECUTION_ID" ]; then - log "No matching pipeline execution yet; retry in ${POLL_INTERVAL}s (remaining $(remaining)s)" + log "No matching post-retag pipeline execution yet; retry in ${POLL_INTERVAL}s (remaining $(remaining)s)" sleep "$POLL_INTERVAL" fi done @@ -77,9 +109,11 @@ while [ -z "$DEPLOYMENT_ID" ] || [ "$DEPLOYMENT_ID" = "None" ]; do done log "CodeDeploy deployment: $DEPLOYMENT_ID" -# Phase C: wait for the traffic cutover (AllowTraffic lifecycle event Succeeded). +# Phase C: wait for the traffic cutover. Require AllowTraffic == Succeeded on +# EVERY ECS target, so a multi-target deploy can't promote while one target is +# still mid-cutover or failed. while true; do - fail_if_expired "AllowTraffic (traffic cutover)" + fail_if_expired "AllowTraffic (traffic cutover) on all targets" dstatus=$(aws deploy get-deployment --deployment-id "$DEPLOYMENT_ID" \ --query 'deploymentInfo.status' --output text 2>/dev/null || true) case "$dstatus" in @@ -88,18 +122,25 @@ while true; do exit 1 ;; esac - target_id=$(aws deploy list-deployment-targets --deployment-id "$DEPLOYMENT_ID" \ - --query 'targetIds[0]' --output text 2>/dev/null || true) - at_status="" - if [ -n "$target_id" ] && [ "$target_id" != "None" ]; then - at_status=$(aws deploy get-deployment-target --deployment-id "$DEPLOYMENT_ID" --target-id "$target_id" \ - --query "deploymentTarget.ecsTarget.lifecycleEvents[?lifecycleEventName=='AllowTraffic'].status | [0]" \ - --output text 2>/dev/null || true) - if [ "$at_status" = "Succeeded" ]; then - log "Traffic cutover complete (AllowTraffic Succeeded) for $DEPLOYMENT_ID" + target_ids=$(aws deploy list-deployment-targets --deployment-id "$DEPLOYMENT_ID" \ + --query 'targetIds' --output text 2>/dev/null || true) + if [ -n "$target_ids" ] && [ "$target_ids" != "None" ]; then + all_ok=1 + ntargets=0 + for tid in $target_ids; do + ntargets=$((ntargets + 1)) + at_status=$(aws deploy get-deployment-target --deployment-id "$DEPLOYMENT_ID" --target-id "$tid" \ + --query "deploymentTarget.ecsTarget.lifecycleEvents[?lifecycleEventName=='AllowTraffic'].status | [0]" \ + --output text 2>/dev/null || true) + if [ "$at_status" != "Succeeded" ]; then + all_ok=0 + fi + done + if [ "$ntargets" -gt 0 ] && [ "$all_ok" = "1" ]; then + log "Traffic cutover complete (AllowTraffic Succeeded on all $ntargets target(s)) for $DEPLOYMENT_ID" exit 0 fi fi - log "Deployment $DEPLOYMENT_ID status=$dstatus AllowTraffic=${at_status:-pending}; wait ${POLL_INTERVAL}s (remaining $(remaining)s)" + log "Deployment $DEPLOYMENT_ID status=$dstatus; not all targets past AllowTraffic; wait ${POLL_INTERVAL}s (remaining $(remaining)s)" sleep "$POLL_INTERVAL" done diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9571ac30c5e..0e004d2d2d0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -182,69 +182,19 @@ jobs: fi bunx trigger.dev@4.4.3 deploy --env preview --branch dev-sim - # Staging: build & upload the Trigger.dev task version WITHOUT promoting it - # (--skip-promotion). New runs keep executing the old version until the promote - # job flips it at the ECS traffic cutover, so this deploy carries zero - # app<->task skew and runs in parallel with the image build. The captured - # version output is consumed by promote-trigger-staging. - deploy-trigger-staging: - name: Deploy Trigger.dev (Staging) + # Main/staging: build & upload the Trigger.dev task version WITHOUT promoting it + # (--skip-promotion). New runs keep executing the OLD promoted version until + # promote-trigger flips it at the ECS traffic cutover — so the app cutting over + # never changes which task version runs until promote-trigger (which depends on + # this job) promotes the version uploaded here. Runs in parallel with the build; + # intentionally NOT gating the app deploy on it, to avoid coupling every app / + # realtime / pii / migration deploy to trigger.dev availability. + deploy-trigger: + name: Deploy Trigger.dev needs: [migrate] - if: github.event_name == 'push' && github.ref == 'refs/heads/staging' - runs-on: blacksmith-4vcpu-ubuntu-2404 - timeout-minutes: 15 - outputs: - version: ${{ steps.deploy.outputs.version }} - steps: - - name: Checkout code - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 - - - name: Setup Bun - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2 - with: - bun-version: 1.3.13 - - - name: Cache Bun dependencies - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5 - with: - path: | - ~/.bun/install/cache - node_modules - **/node_modules - key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }} - restore-keys: | - ${{ runner.os }}-bun- - - - name: Install dependencies - run: bun install --frozen-lockfile - - - name: Deploy to Trigger.dev (skip promotion) - id: deploy - working-directory: ./apps/sim - env: - TRIGGER_ACCESS_TOKEN: ${{ secrets.TRIGGER_ACCESS_TOKEN }} - TRIGGER_PROJECT_ID: ${{ secrets.TRIGGER_PROJECT_ID }} - run: | - set -eo pipefail - if [ -z "$TRIGGER_ACCESS_TOKEN" ] || [ -z "$TRIGGER_PROJECT_ID" ]; then - echo "ERROR: TRIGGER_ACCESS_TOKEN and TRIGGER_PROJECT_ID repo secrets must both be set" >&2 - exit 1 - fi - bunx trigger.dev@4.4.3 deploy --env staging --skip-promotion 2>&1 | tee deploy.log - # Extract the deployed version (e.g. 20260715.2) tied to THIS invocation. - VERSION=$(sed -E 's/\x1b\[[0-9;]*m//g' deploy.log | grep -oE '20[0-9]{6}\.[0-9]+' | tail -n1 || true) - if [ -z "$VERSION" ]; then - echo "ERROR: could not parse deployed version from deploy output" >&2 - exit 1 - fi - echo "Captured deployed version: $VERSION" - echo "version=$VERSION" >> "$GITHUB_OUTPUT" - - # Production: same skip-promotion deploy as staging, for the prod environment. - deploy-trigger-production: - name: Deploy Trigger.dev (Production) - needs: [migrate] - if: github.event_name == 'push' && github.ref == 'refs/heads/main' + if: >- + github.event_name == 'push' && + (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging') runs-on: blacksmith-4vcpu-ubuntu-2404 timeout-minutes: 15 outputs: @@ -278,13 +228,14 @@ jobs: env: TRIGGER_ACCESS_TOKEN: ${{ secrets.TRIGGER_ACCESS_TOKEN }} TRIGGER_PROJECT_ID: ${{ secrets.TRIGGER_PROJECT_ID }} + TRIGGER_ENV: ${{ github.ref == 'refs/heads/main' && 'prod' || 'staging' }} run: | set -eo pipefail if [ -z "$TRIGGER_ACCESS_TOKEN" ] || [ -z "$TRIGGER_PROJECT_ID" ]; then echo "ERROR: TRIGGER_ACCESS_TOKEN and TRIGGER_PROJECT_ID repo secrets must both be set" >&2 exit 1 fi - bunx trigger.dev@4.4.3 deploy --env prod --skip-promotion 2>&1 | tee deploy.log + bunx trigger.dev@4.4.3 deploy --env "$TRIGGER_ENV" --skip-promotion 2>&1 | tee deploy.log # Extract the deployed version (e.g. 20260715.2) tied to THIS invocation. VERSION=$(sed -E 's/\x1b\[[0-9;]*m//g' deploy.log | grep -oE '20[0-9]{6}\.[0-9]+' | tail -n1 || true) if [ -z "$VERSION" ]; then @@ -431,9 +382,13 @@ jobs: id-token: write outputs: # Whether the deploy tag was actually moved (false on a stale-run guard - # skip). promote-trigger-* keys off this so tasks are never promoted when + # skip). promote-trigger keys off this so tasks are never promoted when # the app itself wasn't. promoted: ${{ steps.guard.outputs.fresh }} + # Epoch when the deploy tag was retagged (this push's ECS pipeline trigger). + # promote-trigger passes it to the poll script so a stale pipeline execution + # reusing the same image digest can't satisfy the cutover gate. + retag_epoch: ${{ steps.promote.outputs.retag_epoch }} steps: - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@e7f100cf4c008499ea8adda475de1042d6975c7b # v6 @@ -463,6 +418,7 @@ jobs: fi - name: Promote images to deploy tags + id: promote if: steps.guard.outputs.fresh == 'true' env: ECR_REPOS: >- @@ -471,6 +427,11 @@ jobs: ${{ secrets.ECR_REALTIME }} ${{ secrets.ECR_PII }} run: | + # Record the retag time BEFORE moving any tag — this is when the ECS + # pipeline for this push is triggered. promote-trigger uses it to + # reject an older pipeline execution reusing the same image digest. + echo "retag_epoch=$(date +%s)" >> "$GITHUB_OUTPUT" + REGISTRY="${{ steps.login-ecr.outputs.registry }}" if [ "${{ github.ref }}" = "refs/heads/main" ]; then @@ -493,18 +454,20 @@ jobs: "${REGISTRY}/${repo}:${{ github.sha }}" done - # Staging: promote the skip-promoted Trigger.dev version at the exact moment the - # ECS app deploy shifts traffic (CodeDeploy AllowTraffic), so tasks and app cut - # over in lockstep. The promote-images retag above is what triggers the ECS - # pipeline; this job polls it (via the app image digest) and promotes at cutover. + # Main/staging: promote the skip-promoted Trigger.dev version at the exact moment + # the ECS app deploy shifts traffic (CodeDeploy AllowTraffic on every target), so + # tasks and app cut over in lockstep. The promote-images retag is what triggers + # the ECS pipeline; this job correlates it via the app image digest + retag epoch + # (rejecting a stale execution reusing the digest) and promotes at cutover. # Skipped when promote-images skipped the tag move (stale run) — tasks then # correctly stay on the old version. If the app deploy fails or never cuts over, # promote never fires and this job fails visibly. - promote-trigger-staging: - name: Promote Trigger.dev (Staging) - needs: [promote-images, deploy-trigger-staging] + promote-trigger: + name: Promote Trigger.dev + needs: [promote-images, deploy-trigger] if: >- - github.event_name == 'push' && github.ref == 'refs/heads/staging' && + github.event_name == 'push' && + (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging') && needs.promote-images.outputs.promoted == 'true' runs-on: blacksmith-4vcpu-ubuntu-2404 timeout-minutes: 75 @@ -543,93 +506,25 @@ jobs: - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@e7f100cf4c008499ea8adda475de1042d6975c7b # v6 with: - role-to-assume: ${{ secrets.STAGING_AWS_ROLE_TO_ASSUME }} - aws-region: ${{ secrets.STAGING_AWS_REGION }} + role-to-assume: ${{ github.ref == 'refs/heads/main' && secrets.AWS_ROLE_TO_ASSUME || secrets.STAGING_AWS_ROLE_TO_ASSUME }} + aws-region: ${{ github.ref == 'refs/heads/main' && secrets.AWS_REGION || secrets.STAGING_AWS_REGION }} - name: Wait for ECS traffic cutover - run: | - set -eo pipefail - DIGEST=$(cat digest/app-image-digest.txt) - bash .github/scripts/wait-for-ecs-cutover.sh sim-staging-us-east-1-app-deployment "$DIGEST" - - - name: Promote Trigger.dev version - working-directory: ./apps/sim env: - TRIGGER_ACCESS_TOKEN: ${{ secrets.TRIGGER_ACCESS_TOKEN }} - TRIGGER_PROJECT_ID: ${{ secrets.TRIGGER_PROJECT_ID }} - VERSION: ${{ needs.deploy-trigger-staging.outputs.version }} - run: | - set -eo pipefail - if [ -z "$TRIGGER_ACCESS_TOKEN" ] || [ -z "$TRIGGER_PROJECT_ID" ]; then - echo "ERROR: TRIGGER_ACCESS_TOKEN and TRIGGER_PROJECT_ID repo secrets must both be set" >&2 - exit 1 - fi - if [ -z "$VERSION" ]; then - echo "ERROR: no deployed version passed from deploy-trigger-staging" >&2 - exit 1 - fi - echo "Promoting Trigger.dev version $VERSION (staging) at ECS cutover" - bunx trigger.dev@4.4.3 promote "$VERSION" --env staging - - # Production: same lockstep promotion as staging, for the prod environment. - promote-trigger-production: - name: Promote Trigger.dev (Production) - needs: [promote-images, deploy-trigger-production] - if: >- - github.event_name == 'push' && github.ref == 'refs/heads/main' && - needs.promote-images.outputs.promoted == 'true' - runs-on: blacksmith-4vcpu-ubuntu-2404 - timeout-minutes: 75 - permissions: - contents: read - id-token: write - steps: - - name: Checkout code - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 - - - name: Setup Bun - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2 - with: - bun-version: 1.3.13 - - - name: Cache Bun dependencies - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5 - with: - path: | - ~/.bun/install/cache - node_modules - **/node_modules - key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }} - restore-keys: | - ${{ runner.os }}-bun- - - - name: Install dependencies - run: bun install --frozen-lockfile - - - name: Download app image digest - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 - with: - name: app-image-digest - path: digest - - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@e7f100cf4c008499ea8adda475de1042d6975c7b # v6 - with: - role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} - aws-region: ${{ secrets.AWS_REGION }} - - - name: Wait for ECS traffic cutover + PIPELINE: sim-${{ github.ref == 'refs/heads/main' && 'production' || 'staging' }}-us-east-1-app-deployment + RETAG_EPOCH: ${{ needs.promote-images.outputs.retag_epoch }} run: | set -eo pipefail DIGEST=$(cat digest/app-image-digest.txt) - bash .github/scripts/wait-for-ecs-cutover.sh sim-production-us-east-1-app-deployment "$DIGEST" + bash .github/scripts/wait-for-ecs-cutover.sh "$PIPELINE" "$DIGEST" "$RETAG_EPOCH" - name: Promote Trigger.dev version working-directory: ./apps/sim env: TRIGGER_ACCESS_TOKEN: ${{ secrets.TRIGGER_ACCESS_TOKEN }} TRIGGER_PROJECT_ID: ${{ secrets.TRIGGER_PROJECT_ID }} - VERSION: ${{ needs.deploy-trigger-production.outputs.version }} + TRIGGER_ENV: ${{ github.ref == 'refs/heads/main' && 'prod' || 'staging' }} + VERSION: ${{ needs.deploy-trigger.outputs.version }} run: | set -eo pipefail if [ -z "$TRIGGER_ACCESS_TOKEN" ] || [ -z "$TRIGGER_PROJECT_ID" ]; then @@ -637,11 +532,11 @@ jobs: exit 1 fi if [ -z "$VERSION" ]; then - echo "ERROR: no deployed version passed from deploy-trigger-production" >&2 + echo "ERROR: no deployed version passed from deploy-trigger" >&2 exit 1 fi - echo "Promoting Trigger.dev version $VERSION (production) at ECS cutover" - bunx trigger.dev@4.4.3 promote "$VERSION" --env prod + echo "Promoting Trigger.dev version $VERSION ($TRIGGER_ENV) at ECS cutover" + bunx trigger.dev@4.4.3 promote "$VERSION" --env "$TRIGGER_ENV" # Build ARM64 images for GHCR (main branch only, runs in parallel with # tests). Pushes only the immutable sha tag — latest-arm64/version-arm64 From f7135b058aa5d798f0ca4b7ad9aa5822aad91b2c Mon Sep 17 00:00:00 2001 From: Theodore Li Date: Sun, 19 Jul 2026 13:55:34 -0700 Subject: [PATCH 03/10] fix(ci): widen promote-trigger job timeout above the poll budget --- .github/workflows/ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0e004d2d2d0..2160b50fec1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -470,7 +470,10 @@ jobs: (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging') && needs.promote-images.outputs.promoted == 'true' runs-on: blacksmith-4vcpu-ubuntu-2404 - timeout-minutes: 75 + # Must exceed the poll script's OVERALL_TIMEOUT (70 min, covering a prod deploy + # queued behind a ~50-min bake) PLUS runner setup + the final promote step, so + # the Actions timeout never kills the job before the script's own deadline. + timeout-minutes: 90 permissions: contents: read id-token: write From 0d85d3b76f0ecd400c2390bd7447c6678b2ace45 Mon Sep 17 00:00:00 2001 From: Theodore Li Date: Mon, 20 Jul 2026 10:40:51 -0700 Subject: [PATCH 04/10] fix(ci): hold AWS session for the full poll and skip wait when the app image is unchanged --- .github/workflows/ci.yml | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2160b50fec1..01e962bf9d4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -389,6 +389,9 @@ jobs: # promote-trigger passes it to the poll script so a stale pipeline execution # reusing the same image digest can't satisfy the cutover gate. retag_epoch: ${{ steps.promote.outputs.retag_epoch }} + # 'false' when the app deploy tag didn't move to a new digest (no ECS deploy). + # promote-trigger promotes immediately in that case instead of waiting. + app_image_changed: ${{ steps.promote.outputs.app_image_changed }} steps: - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@e7f100cf4c008499ea8adda475de1042d6975c7b # v6 @@ -440,6 +443,23 @@ jobs: ECR_TAG="staging" fi + # Detect whether the APP deploy tag actually moves to a new digest. If + # this commit's app image is byte-identical to the currently-deployed one + # (e.g. a commit that doesn't touch the app image — docs/CI-only), the + # retag is a no-op, ECR fires no push event, and no ECS app deploy runs. + # promote-trigger reads this to promote immediately instead of waiting for + # a cutover that will never happen. + get_digest() { docker buildx imagetools inspect "$1" 2>/dev/null | awk '/^Digest:/{print $2; exit}'; } + APP_REF="${REGISTRY}/${{ secrets.ECR_APP }}" + NEW_APP_DIGEST="$(get_digest "${APP_REF}:${{ github.sha }}")" + PREV_APP_DIGEST="$(get_digest "${APP_REF}:${ECR_TAG}" || true)" + if [ -n "$NEW_APP_DIGEST" ] && [ "$NEW_APP_DIGEST" = "$PREV_APP_DIGEST" ]; then + echo "app_image_changed=false" >> "$GITHUB_OUTPUT" + echo "ℹ️ App deploy tag ${ECR_TAG} already points at ${NEW_APP_DIGEST}; no ECS app deploy will be triggered." + else + echo "app_image_changed=true" >> "$GITHUB_OUTPUT" + fi + # Verify every sha image exists before moving any deploy tag, so a # missing/expired image aborts the whole promotion up front. for repo in $ECR_REPOS; do @@ -511,8 +531,17 @@ jobs: with: role-to-assume: ${{ github.ref == 'refs/heads/main' && secrets.AWS_ROLE_TO_ASSUME || secrets.STAGING_AWS_ROLE_TO_ASSUME }} aws-region: ${{ github.ref == 'refs/heads/main' && secrets.AWS_REGION || secrets.STAGING_AWS_REGION }} - + # The poll can run up to ~70 min (prod deploy queued behind a bake), which + # outlasts the default 1h session. Hold the session for the full job so AWS + # calls don't start failing mid-poll. Requires the deploy role's + # MaxSessionDuration to be >= this value (roles are managed outside the repo). + role-duration-seconds: 5400 + + # Skip the cutover wait when the app image didn't change (no ECS deploy was + # triggered) — otherwise the poll would hang until timeout. Promotion still + # runs below, immediately, since there is no app cutover to align with. - name: Wait for ECS traffic cutover + if: needs.promote-images.outputs.app_image_changed == 'true' env: PIPELINE: sim-${{ github.ref == 'refs/heads/main' && 'production' || 'staging' }}-us-east-1-app-deployment RETAG_EPOCH: ${{ needs.promote-images.outputs.retag_epoch }} @@ -538,7 +567,7 @@ jobs: echo "ERROR: no deployed version passed from deploy-trigger" >&2 exit 1 fi - echo "Promoting Trigger.dev version $VERSION ($TRIGGER_ENV) at ECS cutover" + echo "Promoting Trigger.dev version $VERSION ($TRIGGER_ENV)" bunx trigger.dev@4.4.3 promote "$VERSION" --env "$TRIGGER_ENV" # Build ARM64 images for GHCR (main branch only, runs in parallel with From 7bdaa1d868fa7eff58a1edd670e6231f9197b085 Mon Sep 17 00:00:00 2001 From: Theodore Li Date: Mon, 20 Jul 2026 10:44:25 -0700 Subject: [PATCH 05/10] feat(ci): extend lockstep Trigger.dev promotion to dev (preview branch) --- .github/workflows/ci.yml | 146 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 141 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 01e962bf9d4..fc8f708d2f8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -127,7 +127,19 @@ jobs: env: ECR_REPO: ${{ matrix.ecr_repo_secret == 'ECR_APP' && secrets.ECR_APP || matrix.ecr_repo_secret == 'ECR_MIGRATIONS' && secrets.ECR_MIGRATIONS || matrix.ecr_repo_secret == 'ECR_REALTIME' && secrets.ECR_REALTIME || matrix.ecr_repo_secret == 'ECR_PII' && secrets.ECR_PII || '' }} + # App leg only: capture the digest the :dev tag currently points at, BEFORE + # this build overwrites it, so promote-trigger-dev can tell whether the app + # image actually changed (a no-op :dev push triggers no ECS deploy). + - name: Capture previous :dev app digest + id: prevdigest + if: matrix.ecr_repo_secret == 'ECR_APP' + run: | + REF="${{ steps.login-ecr.outputs.registry }}/${{ steps.ecr-repo.outputs.name }}:dev" + PREV=$(docker buildx imagetools inspect "$REF" 2>/dev/null | awk '/^Digest:/{print $2; exit}' || true) + echo "digest=${PREV}" >> "$GITHUB_OUTPUT" + - name: Build and push + id: build uses: useblacksmith/build-push-action@fb9e3e6a9299c78462bfadd0d93352c316adc9b8 # v2 with: context: . @@ -138,15 +150,105 @@ jobs: provenance: false sbom: false - # Dev: deploy Trigger.dev background tasks to the preview "dev-sim" branch. - # Gated after migrate-dev for the same reason as build-dev — the new task - # code runs against the dev DB, so the schema must be pushed first. + # App leg only: publish the metadata promote-trigger-dev needs to correlate + # this push to its dev ECS deploy and decide whether to wait. Dev has no + # promote-images job, so this stands in for its retag_epoch/app_image_changed + # outputs. The epoch is recorded just after the :dev push (the pipeline trigger). + - name: Publish dev cutover metadata + if: matrix.ecr_repo_secret == 'ECR_APP' + run: | + mkdir -p dev-meta + NEW="${{ steps.build.outputs.digest }}" + PREV="${{ steps.prevdigest.outputs.digest }}" + echo "$NEW" > dev-meta/digest.txt + date +%s > dev-meta/retag_epoch.txt + if [ -n "$NEW" ] && [ "$NEW" = "$PREV" ]; then + echo "false" > dev-meta/app_image_changed.txt + echo "ℹ️ :dev already points at ${NEW}; no ECS dev deploy will be triggered." + else + echo "true" > dev-meta/app_image_changed.txt + fi + + - name: Upload dev cutover metadata + if: matrix.ecr_repo_secret == 'ECR_APP' + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: dev-cutover-meta + path: dev-meta/ + retention-days: 1 + + # Dev: build & upload the Trigger.dev task version WITHOUT promoting it + # (--skip-promotion) to the preview "dev-sim" branch. promote-trigger-dev flips + # it at the dev ECS traffic cutover. Gated after migrate-dev so the schema is + # pushed before the new task version can run against the dev DB. deploy-trigger-dev: name: Deploy Trigger.dev (Dev) needs: [migrate-dev] if: github.event_name == 'push' && github.ref == 'refs/heads/dev' runs-on: blacksmith-4vcpu-ubuntu-2404 timeout-minutes: 15 + outputs: + version: ${{ steps.deploy.outputs.version }} + steps: + - name: Checkout code + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 + + - name: Setup Bun + uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2 + with: + bun-version: 1.3.13 + + - name: Cache Bun dependencies + uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5 + with: + path: | + ~/.bun/install/cache + node_modules + **/node_modules + key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }} + restore-keys: | + ${{ runner.os }}-bun- + + - name: Install dependencies + run: bun install --frozen-lockfile + + - name: Deploy to Trigger.dev (skip promotion) + id: deploy + working-directory: ./apps/sim + env: + TRIGGER_ACCESS_TOKEN: ${{ secrets.DEV_TRIGGER_ACCESS_TOKEN }} + TRIGGER_PROJECT_ID: ${{ secrets.TRIGGER_PROJECT_ID }} + run: | + set -eo pipefail + if [ -z "$TRIGGER_ACCESS_TOKEN" ] || [ -z "$TRIGGER_PROJECT_ID" ]; then + echo "ERROR: DEV_TRIGGER_ACCESS_TOKEN and TRIGGER_PROJECT_ID repo secrets must both be set" >&2 + exit 1 + fi + bunx trigger.dev@4.4.3 deploy --env preview --branch dev-sim --skip-promotion 2>&1 | tee deploy.log + VERSION=$(sed -E 's/\x1b\[[0-9;]*m//g' deploy.log | grep -oE '20[0-9]{6}\.[0-9]+' | tail -n1 || true) + if [ -z "$VERSION" ]; then + echo "ERROR: could not parse deployed version from deploy output" >&2 + exit 1 + fi + echo "Captured deployed version: $VERSION" + echo "version=$VERSION" >> "$GITHUB_OUTPUT" + + # Dev: promote the skip-promoted preview version at the dev ECS traffic cutover. + # Dev has no promote-images gate (build-dev pushes :dev directly), so the digest, + # trigger epoch, and app-image-changed signal come from build-dev's artifact. + # trigger.dev supports promoting a specific preview branch: promote --env preview + # --branch dev-sim. + promote-trigger-dev: + name: Promote Trigger.dev (Dev) + needs: [build-dev, deploy-trigger-dev] + if: github.event_name == 'push' && github.ref == 'refs/heads/dev' + runs-on: blacksmith-4vcpu-ubuntu-2404 + # Dev bake is 5 min; the poll budget (30 min) and session (40 min) are sized for + # that with margin, well short of the prod path's 70/90. + timeout-minutes: 40 + permissions: + contents: read + id-token: write steps: - name: Checkout code uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 @@ -170,17 +272,51 @@ jobs: - name: Install dependencies run: bun install --frozen-lockfile - - name: Deploy to Trigger.dev + - name: Download dev cutover metadata + uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 + with: + name: dev-cutover-meta + path: dev-meta + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@e7f100cf4c008499ea8adda475de1042d6975c7b # v6 + with: + role-to-assume: ${{ secrets.DEV_AWS_ROLE_TO_ASSUME }} + aws-region: ${{ secrets.DEV_AWS_REGION }} + role-duration-seconds: 2400 + + - name: Wait for ECS traffic cutover + env: + OVERALL_TIMEOUT: "1800" + run: | + set -eo pipefail + CHANGED=$(cat dev-meta/app_image_changed.txt) + if [ "$CHANGED" != "true" ]; then + echo "App image unchanged — no dev ECS deploy triggered; promoting immediately." + exit 0 + fi + DIGEST=$(cat dev-meta/digest.txt) + EPOCH=$(cat dev-meta/retag_epoch.txt) + bash .github/scripts/wait-for-ecs-cutover.sh sim-dev-us-east-1-app-deployment "$DIGEST" "$EPOCH" + + - name: Promote Trigger.dev version working-directory: ./apps/sim env: TRIGGER_ACCESS_TOKEN: ${{ secrets.DEV_TRIGGER_ACCESS_TOKEN }} TRIGGER_PROJECT_ID: ${{ secrets.TRIGGER_PROJECT_ID }} + VERSION: ${{ needs.deploy-trigger-dev.outputs.version }} run: | + set -eo pipefail if [ -z "$TRIGGER_ACCESS_TOKEN" ] || [ -z "$TRIGGER_PROJECT_ID" ]; then echo "ERROR: DEV_TRIGGER_ACCESS_TOKEN and TRIGGER_PROJECT_ID repo secrets must both be set" >&2 exit 1 fi - bunx trigger.dev@4.4.3 deploy --env preview --branch dev-sim + if [ -z "$VERSION" ]; then + echo "ERROR: no deployed version passed from deploy-trigger-dev" >&2 + exit 1 + fi + echo "Promoting Trigger.dev version $VERSION (preview / dev-sim)" + bunx trigger.dev@4.4.3 promote "$VERSION" --env preview --branch dev-sim # Main/staging: build & upload the Trigger.dev task version WITHOUT promoting it # (--skip-promotion). New runs keep executing the OLD promoted version until From 2f006f06505d4d94d705b04ad9da2c544685637d Mon Sep 17 00:00:00 2001 From: Theodore Li Date: Mon, 20 Jul 2026 10:54:04 -0700 Subject: [PATCH 06/10] fix(ci): don't block dev task promotion on a non-app build-dev leg failure --- .github/workflows/ci.yml | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fc8f708d2f8..a054920b9f3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -241,7 +241,15 @@ jobs: promote-trigger-dev: name: Promote Trigger.dev (Dev) needs: [build-dev, deploy-trigger-dev] - if: github.event_name == 'push' && github.ref == 'refs/heads/dev' + # Run as long as the task upload succeeded, even if a NON-app build-dev leg + # (realtime/pii/migrations) failed: the app leg pushes :dev independently and + # may have already triggered the ECS deploy, so an unrelated image failure must + # not strand the app on the old task version. The app-metadata artifact (only + # the app leg uploads it) is the real signal that an app deploy happened. + if: >- + !cancelled() && + github.event_name == 'push' && github.ref == 'refs/heads/dev' && + needs.deploy-trigger-dev.result == 'success' runs-on: blacksmith-4vcpu-ubuntu-2404 # Dev bake is 5 min; the poll budget (30 min) and session (40 min) are sized for # that with margin, well short of the prod path's 70/90. @@ -272,13 +280,28 @@ jobs: - name: Install dependencies run: bun install --frozen-lockfile + # Tolerate a missing artifact: it's only uploaded by the app leg, so its + # absence means the app image didn't build → no ECS deploy happened. - name: Download dev cutover metadata + id: meta + continue-on-error: true uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 with: name: dev-cutover-meta path: dev-meta + - name: Determine whether an app deploy happened + id: appdeploy + run: | + if [ -f dev-meta/app_image_changed.txt ]; then + echo "deployed=true" >> "$GITHUB_OUTPUT" + else + echo "deployed=false" >> "$GITHUB_OUTPUT" + echo "::warning::No app-image metadata (app leg did not build); skipping dev task promotion." + fi + - name: Configure AWS credentials + if: steps.appdeploy.outputs.deployed == 'true' uses: aws-actions/configure-aws-credentials@e7f100cf4c008499ea8adda475de1042d6975c7b # v6 with: role-to-assume: ${{ secrets.DEV_AWS_ROLE_TO_ASSUME }} @@ -286,6 +309,7 @@ jobs: role-duration-seconds: 2400 - name: Wait for ECS traffic cutover + if: steps.appdeploy.outputs.deployed == 'true' env: OVERALL_TIMEOUT: "1800" run: | @@ -300,6 +324,7 @@ jobs: bash .github/scripts/wait-for-ecs-cutover.sh sim-dev-us-east-1-app-deployment "$DIGEST" "$EPOCH" - name: Promote Trigger.dev version + if: steps.appdeploy.outputs.deployed == 'true' working-directory: ./apps/sim env: TRIGGER_ACCESS_TOKEN: ${{ secrets.DEV_TRIGGER_ACCESS_TOKEN }} From a4483d41d35fea2104ff108ae3382b3ebadd8c9d Mon Sep 17 00:00:00 2001 From: Theodore Li Date: Mon, 20 Jul 2026 11:21:57 -0700 Subject: [PATCH 07/10] chore(ci): use one Trigger.dev PAT for all envs (drop DEV_TRIGGER_ACCESS_TOKEN) --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a054920b9f3..f5b029600ac 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -216,12 +216,12 @@ jobs: id: deploy working-directory: ./apps/sim env: - TRIGGER_ACCESS_TOKEN: ${{ secrets.DEV_TRIGGER_ACCESS_TOKEN }} + TRIGGER_ACCESS_TOKEN: ${{ secrets.TRIGGER_ACCESS_TOKEN }} TRIGGER_PROJECT_ID: ${{ secrets.TRIGGER_PROJECT_ID }} run: | set -eo pipefail if [ -z "$TRIGGER_ACCESS_TOKEN" ] || [ -z "$TRIGGER_PROJECT_ID" ]; then - echo "ERROR: DEV_TRIGGER_ACCESS_TOKEN and TRIGGER_PROJECT_ID repo secrets must both be set" >&2 + echo "ERROR: TRIGGER_ACCESS_TOKEN and TRIGGER_PROJECT_ID repo secrets must both be set" >&2 exit 1 fi bunx trigger.dev@4.4.3 deploy --env preview --branch dev-sim --skip-promotion 2>&1 | tee deploy.log @@ -327,13 +327,13 @@ jobs: if: steps.appdeploy.outputs.deployed == 'true' working-directory: ./apps/sim env: - TRIGGER_ACCESS_TOKEN: ${{ secrets.DEV_TRIGGER_ACCESS_TOKEN }} + TRIGGER_ACCESS_TOKEN: ${{ secrets.TRIGGER_ACCESS_TOKEN }} TRIGGER_PROJECT_ID: ${{ secrets.TRIGGER_PROJECT_ID }} VERSION: ${{ needs.deploy-trigger-dev.outputs.version }} run: | set -eo pipefail if [ -z "$TRIGGER_ACCESS_TOKEN" ] || [ -z "$TRIGGER_PROJECT_ID" ]; then - echo "ERROR: DEV_TRIGGER_ACCESS_TOKEN and TRIGGER_PROJECT_ID repo secrets must both be set" >&2 + echo "ERROR: TRIGGER_ACCESS_TOKEN and TRIGGER_PROJECT_ID repo secrets must both be set" >&2 exit 1 fi if [ -z "$VERSION" ]; then From c7c2aabcb51e1a6608910391122a0e0d56babb9c Mon Sep 17 00:00:00 2001 From: Theodore Li Date: Mon, 20 Jul 2026 11:33:17 -0700 Subject: [PATCH 08/10] fix(ci): reliable digest reads for no-op detection, robust version parse, pre-push dev epoch --- .github/workflows/ci.yml | 68 ++++++++++++++++++++++++++++++---------- 1 file changed, 52 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f5b029600ac..5f02813532e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -127,15 +127,18 @@ jobs: env: ECR_REPO: ${{ matrix.ecr_repo_secret == 'ECR_APP' && secrets.ECR_APP || matrix.ecr_repo_secret == 'ECR_MIGRATIONS' && secrets.ECR_MIGRATIONS || matrix.ecr_repo_secret == 'ECR_REALTIME' && secrets.ECR_REALTIME || matrix.ecr_repo_secret == 'ECR_PII' && secrets.ECR_PII || '' }} - # App leg only: capture the digest the :dev tag currently points at, BEFORE - # this build overwrites it, so promote-trigger-dev can tell whether the app - # image actually changed (a no-op :dev push triggers no ECS deploy). - - name: Capture previous :dev app digest + # App leg only: stamp the trigger epoch and capture the :dev digest BEFORE the + # build/push overwrites it. Stamping the epoch pre-build (not after the push, + # like it was) guarantees it precedes the :dev push that triggers the pipeline, + # so the dev ECS execution's startTime can't land before the epoch and get + # rejected by the cutover poll. The digest read uses the ECR API so an absent + # tag ("None", first deploy → changed) is distinct from a read error. + - name: Capture pre-build :dev state id: prevdigest if: matrix.ecr_repo_secret == 'ECR_APP' run: | - REF="${{ steps.login-ecr.outputs.registry }}/${{ steps.ecr-repo.outputs.name }}:dev" - PREV=$(docker buildx imagetools inspect "$REF" 2>/dev/null | awk '/^Digest:/{print $2; exit}' || true) + echo "epoch=$(date +%s)" >> "$GITHUB_OUTPUT" + PREV="$(aws ecr batch-get-image --repository-name "${{ steps.ecr-repo.outputs.name }}" --image-ids imageTag=dev --query 'images[0].imageId.imageDigest' --output text 2>/dev/null)" || PREV="__ERR__" echo "digest=${PREV}" >> "$GITHUB_OUTPUT" - name: Build and push @@ -153,16 +156,22 @@ jobs: # App leg only: publish the metadata promote-trigger-dev needs to correlate # this push to its dev ECS deploy and decide whether to wait. Dev has no # promote-images job, so this stands in for its retag_epoch/app_image_changed - # outputs. The epoch is recorded just after the :dev push (the pipeline trigger). + # outputs. The epoch and prev digest come from the pre-build step above. - name: Publish dev cutover metadata if: matrix.ecr_repo_secret == 'ECR_APP' run: | mkdir -p dev-meta NEW="${{ steps.build.outputs.digest }}" PREV="${{ steps.prevdigest.outputs.digest }}" + if [ -z "$NEW" ]; then + echo "ERROR: build did not report an image digest" >&2 + exit 1 + fi echo "$NEW" > dev-meta/digest.txt - date +%s > dev-meta/retag_epoch.txt - if [ -n "$NEW" ] && [ "$NEW" = "$PREV" ]; then + echo "${{ steps.prevdigest.outputs.epoch }}" > dev-meta/retag_epoch.txt + # PREV=__ERR__ (read failed) falls through to changed=true (wait) — the safe + # direction. A real no-op is detected when the read succeeds and matches. + if [ "$PREV" != "__ERR__" ] && [ "$NEW" = "$PREV" ]; then echo "false" > dev-meta/app_image_changed.txt echo "ℹ️ :dev already points at ${NEW}; no ECS dev deploy will be triggered." else @@ -225,7 +234,16 @@ jobs: exit 1 fi bunx trigger.dev@4.4.3 deploy --env preview --branch dev-sim --skip-promotion 2>&1 | tee deploy.log - VERSION=$(sed -E 's/\x1b\[[0-9;]*m//g' deploy.log | grep -oE '20[0-9]{6}\.[0-9]+' | tail -n1 || true) + # Anchor on the "version" keyword and take the FIRST match: with + # --skip-promotion the CLI can print the unchanged current version AFTER + # the one it just deployed, and dashboard URLs carry other IDs — so a bare + # last-match could promote the wrong version. Fall back to a bare + # first-match only if no version-labelled line is present. + CLEAN=$(sed -E 's/\x1b\[[0-9;]*m//g' deploy.log) + VERSION=$(printf '%s\n' "$CLEAN" | grep -oiE 'version[[:space:]]+v?20[0-9]{6}\.[0-9]+' | grep -oE '20[0-9]{6}\.[0-9]+' | head -n1 || true) + if [ -z "$VERSION" ]; then + VERSION=$(printf '%s\n' "$CLEAN" | grep -oE '20[0-9]{6}\.[0-9]+' | head -n1 || true) + fi if [ -z "$VERSION" ]; then echo "ERROR: could not parse deployed version from deploy output" >&2 exit 1 @@ -398,7 +416,16 @@ jobs: fi bunx trigger.dev@4.4.3 deploy --env "$TRIGGER_ENV" --skip-promotion 2>&1 | tee deploy.log # Extract the deployed version (e.g. 20260715.2) tied to THIS invocation. - VERSION=$(sed -E 's/\x1b\[[0-9;]*m//g' deploy.log | grep -oE '20[0-9]{6}\.[0-9]+' | tail -n1 || true) + # Anchor on the "version" keyword and take the FIRST match: with + # --skip-promotion the CLI can print the unchanged current version AFTER + # the one it just deployed, and dashboard URLs carry other IDs — so a bare + # last-match could promote the wrong version. Fall back to a bare + # first-match only if no version-labelled line is present. + CLEAN=$(sed -E 's/\x1b\[[0-9;]*m//g' deploy.log) + VERSION=$(printf '%s\n' "$CLEAN" | grep -oiE 'version[[:space:]]+v?20[0-9]{6}\.[0-9]+' | grep -oE '20[0-9]{6}\.[0-9]+' | head -n1 || true) + if [ -z "$VERSION" ]; then + VERSION=$(printf '%s\n' "$CLEAN" | grep -oE '20[0-9]{6}\.[0-9]+' | head -n1 || true) + fi if [ -z "$VERSION" ]; then echo "ERROR: could not parse deployed version from deploy output" >&2 exit 1 @@ -610,11 +637,20 @@ jobs: # retag is a no-op, ECR fires no push event, and no ECS app deploy runs. # promote-trigger reads this to promote immediately instead of waiting for # a cutover that will never happen. - get_digest() { docker buildx imagetools inspect "$1" 2>/dev/null | awk '/^Digest:/{print $2; exit}'; } - APP_REF="${REGISTRY}/${{ secrets.ECR_APP }}" - NEW_APP_DIGEST="$(get_digest "${APP_REF}:${{ github.sha }}")" - PREV_APP_DIGEST="$(get_digest "${APP_REF}:${ECR_TAG}" || true)" - if [ -n "$NEW_APP_DIGEST" ] && [ "$NEW_APP_DIGEST" = "$PREV_APP_DIGEST" ]; then + # + # Read digests via the ECR API, which cleanly returns "None" for an absent + # tag (first deploy → changed) vs a non-zero exit on a real read error. On + # a read error we fall through to changed=true (wait) — the safe direction + # (old tasks stay current, job fails visibly) rather than promoting early. + APP_REPO="${{ secrets.ECR_APP }}" + ecr_digest() { aws ecr batch-get-image --repository-name "$1" --image-ids imageTag="$2" --query 'images[0].imageId.imageDigest' --output text 2>/dev/null; } + NEW_APP_DIGEST="$(ecr_digest "$APP_REPO" "${{ github.sha }}")" || NEW_APP_DIGEST="__ERR__" + PREV_APP_DIGEST="$(ecr_digest "$APP_REPO" "${ECR_TAG}")" || PREV_APP_DIGEST="__ERR__" + if [ "$NEW_APP_DIGEST" = "__ERR__" ] || [ "$NEW_APP_DIGEST" = "None" ] || [ -z "$NEW_APP_DIGEST" ]; then + echo "ERROR: could not resolve the new app image digest for ${{ github.sha }}" >&2 + exit 1 + fi + if [ "$PREV_APP_DIGEST" != "__ERR__" ] && [ "$NEW_APP_DIGEST" = "$PREV_APP_DIGEST" ]; then echo "app_image_changed=false" >> "$GITHUB_OUTPUT" echo "ℹ️ App deploy tag ${ECR_TAG} already points at ${NEW_APP_DIGEST}; no ECS app deploy will be triggered." else From 2d908f830fb79d5f824f0ce1d36941c0c7281898 Mon Sep 17 00:00:00 2001 From: Theodore Li Date: Mon, 20 Jul 2026 11:41:41 -0700 Subject: [PATCH 09/10] fix(ci): give dev promote-trigger a 20-min margin over its poll budget --- .github/workflows/ci.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5f02813532e..34736c94a54 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -269,8 +269,10 @@ jobs: github.event_name == 'push' && github.ref == 'refs/heads/dev' && needs.deploy-trigger-dev.result == 'success' runs-on: blacksmith-4vcpu-ubuntu-2404 - # Dev bake is 5 min; the poll budget (30 min) and session (40 min) are sized for - # that with margin, well short of the prod path's 70/90. + # Dev bake is 5 min and dev deploys don't queue behind a bake (serialized by the + # ci- group), so a 20-min poll is ample; the 40-min job leaves ~20 min for + # setup + promote above it (mirrors the prod 90-vs-70 margin), and the 40-min + # session outlasts the poll. timeout-minutes: 40 permissions: contents: read @@ -329,7 +331,7 @@ jobs: - name: Wait for ECS traffic cutover if: steps.appdeploy.outputs.deployed == 'true' env: - OVERALL_TIMEOUT: "1800" + OVERALL_TIMEOUT: "1200" run: | set -eo pipefail CHANGED=$(cat dev-meta/app_image_changed.txt) From 4b9c850b689c8c8cb1bbc993e01af2ab1e46af13 Mon Sep 17 00:00:00 2001 From: Theodore Li Date: Mon, 20 Jul 2026 11:47:42 -0700 Subject: [PATCH 10/10] fix(ci): require promote-images + deploy-trigger success explicitly for promote-trigger --- .github/workflows/ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 34736c94a54..3d183fb87cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -684,9 +684,15 @@ jobs: promote-trigger: name: Promote Trigger.dev needs: [promote-images, deploy-trigger] + # Require both upstreams to have SUCCEEDED explicitly (not just promoted==true): + # a job if without a status-check function keeps the implicit success() gate, but + # spelling it out removes any doubt that a failed promote-images/deploy-trigger + # can't reach this job and promote tasks with no app retag/cutover. if: >- github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging') && + needs.promote-images.result == 'success' && + needs.deploy-trigger.result == 'success' && needs.promote-images.outputs.promoted == 'true' runs-on: blacksmith-4vcpu-ubuntu-2404 # Must exceed the poll script's OVERALL_TIMEOUT (70 min, covering a prod deploy