Skip to content

Boost stop command transcription #249

Boost stop command transcription

Boost stop command transcription #249

Workflow file for this run

name: Deploy staging
on:
push:
branches:
- staging
paths:
- "apps/iris-api/**"
- "apps/iris-voice/**"
- "apps/iris-sound-recognition/**"
- "apps/iris-speaker-id/**"
- "infra/aws/**"
- "patches/**"
- "package.json"
- "pnpm-lock.yaml"
- "pnpm-workspace.yaml"
- ".github/workflows/deploy-staging.yml"
workflow_dispatch:
permissions:
contents: read
id-token: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
deploy:
name: Deploy Iris staging
runs-on: blacksmith-4vcpu-ubuntu-2404
environment: staging
timeout-minutes: 60
env:
AWS_REGION: us-west-2
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 50
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.33.2
run_install: false
- name: Setup Node
uses: actions/setup-node@v6
with:
node-version: 22
cache: pnpm
cache-dependency-path: pnpm-lock.yaml
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Typecheck
run: pnpm typecheck
- name: Check staging deploy configuration
env:
AWS_ROLE_TO_ASSUME: ${{ secrets.AWS_ROLE_TO_ASSUME }}
run: |
if [ -z "$AWS_ROLE_TO_ASSUME" ]; then
echo "Missing GitHub Environment secret: AWS_ROLE_TO_ASSUME" >&2
exit 1
fi
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v6.1.0
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: ${{ env.AWS_REGION }}
role-session-name: iris-staging-deploy
- name: Setup Blacksmith Docker builder
uses: useblacksmith/setup-docker-builder@v1
with:
max-cache-size-mb: "102400"
- name: Choose CDK deployment mode
id: deploy-mode
run: |
hotswap_args="--hotswap-fallback --require-approval never"
full_args="--require-approval never"
if [ "${{ github.event_name }}" != "push" ]; then
echo "args=${full_args}" >> "$GITHUB_OUTPUT"
exit 0
fi
base_sha="${{ github.event.before }}"
if [ -z "$base_sha" ] || [ "$base_sha" = "0000000000000000000000000000000000000000" ]; then
echo "args=${full_args}" >> "$GITHUB_OUTPUT"
exit 0
fi
if ! git cat-file -e "${base_sha}^{commit}" 2>/dev/null; then
git fetch --no-tags --depth=50 origin "${{ github.ref_name }}"
fi
changed_files="$(git diff --name-only "$base_sha" "$GITHUB_SHA")"
if printf '%s\n' "$changed_files" | grep -Eq '^(infra/aws/|\.github/workflows/deploy-staging\.yml|package\.json|pnpm-lock\.yaml|pnpm-workspace\.yaml)'; then
echo "args=${full_args}" >> "$GITHUB_OUTPUT"
else
echo "args=${hotswap_args}" >> "$GITHUB_OUTPUT"
fi
- name: Wait for previous stack update
run: |
stack_name="iris-api-staging"
deadline=$((SECONDS + 1800))
rollback_recovery_started=0
while true; do
describe_output="$(aws cloudformation describe-stacks \
--stack-name "$stack_name" \
--query 'Stacks[0].StackStatus' \
--output text 2>&1)" || {
if printf '%s\n' "$describe_output" | grep -q "does not exist"; then
echo "$stack_name does not exist yet; continuing."
break
fi
printf '%s\n' "$describe_output" >&2
exit 1
}
status="$describe_output"
case "$status" in
*_IN_PROGRESS)
if [ "$SECONDS" -ge "$deadline" ]; then
echo "Timed out waiting for $stack_name to finish $status" >&2
exit 1
fi
echo "$stack_name is $status; waiting before deploy..."
sleep 30
;;
UPDATE_ROLLBACK_FAILED)
if [ "$rollback_recovery_started" -eq 0 ]; then
echo "$stack_name is $status; asking CloudFormation to continue rollback..."
if ! aws cloudformation continue-update-rollback --stack-name "$stack_name"; then
echo "Could not continue rollback for $stack_name. The deploy role needs cloudformation:ContinueUpdateRollback or the stack needs manual recovery." >&2
exit 1
fi
rollback_recovery_started=1
sleep 30
else
echo "$stack_name is still $status after recovery request; manual resource recovery is required." >&2
exit 1
fi
;;
ROLLBACK_COMPLETE|ROLLBACK_FAILED)
echo "$stack_name is $status and needs manual recovery before deploy." >&2
exit 1
;;
*)
echo "$stack_name is $status; continuing."
break
;;
esac
done
- name: Deploy staging CDK stack
run: pnpm --filter @iris/aws-infra cdk deploy iris-api-staging -c environment=staging ${{ steps.deploy-mode.outputs.args }}