CI/CD Pipeline & First Deploy
Every npx deploy-stack run generates .github/workflows/deploy.yml. This page explains what that pipeline does, when it runs, and why your site returns 503 until the first push completes.
When it runs
Section titled “When it runs”The workflow triggers on two events (templates/github/deploy.yml):
- A
pushto your deploy branch ({{DEPLOY_BRANCH}}, chosen during setup). - A weekly Sunday cron (
0 0 * * 0) that re-applies the Terraform configuration, so drift and base-image updates converge automatically.
The region, ECR repository, ECS cluster, and ECS service names are baked in at generation time as <project>-repo, <project>-cluster, and <project>-service.
No stored AWS keys
Section titled “No stored AWS keys”Authentication uses GitHub OIDC, not long-lived credentials. The workflow declares:
permissions: id-token: write contents: readand assumes the {{PROJECT_NAME}}-github-actions-role IAM role created by terraform/oidc.tf. There is nothing to rotate and no secret to leak. (If your AWS account already has a GitHub OIDC provider, set create_oidc_provider = false in terraform/oidc.tf — see apply.)
The five stages
Section titled “The five stages”- IaC security scan. Trivy scans
terraform/for vulnerabilities, secrets, and misconfigurations (CRITICAL,HIGH). It is informational only (exit-code: '0'), so it never blocks the build; results land in the GitHub step summary. - Infrastructure sync. The
anton-codes-iac/deploy-stack-action@v1step runs Terraform againstterraform/, so infrastructure changes committed alongside code are applied before the new image rolls out. - Build & push. The workflow logs in to Amazon ECR, runs
docker buildon your generatedDockerfile, and tags the resultlatest. - Container scan. Trivy scans the built image (
os,library,ignore-unfixed: true), again informational only with results in the step summary. - Deploy. The image is pushed to ECR and the workflow forces a new ECS deployment (
aws ecs update-service --force-new-deployment), which rolls the new image across your tasks behind the ALB.
Why you see a 503 first
Section titled “Why you see a 503 first”npx deploy-stack apply provisions the ALB, cluster, and service, but no container image exists until this workflow runs once. Pushing to your deploy branch (git add . && git commit -m "ci: infra" && git push) builds and deploys the first image, clearing the 503. If the service stays unhealthy after that, run npx deploy-stack diagnose — usually the container failed its ALB health check (see Dockerfiles).
Related workflows
Section titled “Related workflows”preview.yml/teardown.ymlexist only when ephemeral PR previews are enabled. See Ephemeral PR Previews.- Secrets are injected at deploy time from AWS Secrets Manager, never from the repo. See Secrets Management.