Overview
The starter kit ships with GitHub Actions workflows generated by Projen so every merge to your default branch produces a deterministic deploy. This guide explains the lifecycle from merge to rollout and how to interact with the pipelines.
Trigger flow
- Push or merge into
main
: Projen creates a workflow namedcdk-deploy-<env>
for each environment. The first environment inenvironmentConfigs
(typicallytest
) runs on every push tomain
. - Environment chaining: Subsequent environments trigger via
workflow_run
when the previous deploy finishes successfully. For example,cdk-deploy-production
waits forcdk-deploy-test
to succeed before starting. - Pull requests: Branch deploy workflows named
cdk-deploy-<env>-branch
run whenenableBranchDeploy
is true for that environment. They deploy stacks with branch suffixes so previews stay isolated. Cleanup is handled bycdk-destroy-<env>-branch
on branch deletion or PR close. - Manual runs: Every workflow exposes the
workflow_dispatch
trigger, enabling re-runs or ad-hoc deploys straight from the GitHub Actions UI.
What each deploy job does
Inside the deploy
job (see createCdkDeploymentWorkflows
) GitHub Actions performs:
- Checkout & setup:
actions/checkout
pulls the repo, thenactions/setup-node
installs the Node.js version from.projenrc.ts
. - Install dependencies:
npm ci
installs dependencies exactly as defined inpackage-lock.json
. - Assume the OIDC role:
aws-actions/configure-aws-credentials@v4
exchanges the GitHub Actions identity for the IAM role created byFoundationStack
. - Synth: Runs
npm run <env>:synth
, ensuring CloudFormation templates match expectations before deploying. - Deploy: Runs
npm run <env>:deploy:all
, deploying the stacks defined insrc/main.ts
to the target AWS account and region.
For branch deploy jobs, the same steps run, but Projen injects GIT_BRANCH_REF
so stack names include a branch suffix. Destroy workflows call npm run <env>:branch:destroy:all
with the proper branch reference.
Monitoring and troubleshooting
- GitHub Actions UI: track the workflow progress directly in
Actions
. Logs show the exact Projen task executing so you can reproduce locally. - CloudFormation stack events: The stack names match
createEnvResourceName('StackName')
, so failures are easy to locate in the AWS console. - Rerunning: Use
workflow_dispatch
or the "Re-run jobs" button after fixing issues. Just ensure the branch you rerun from still matches the intended state.
Before you push
- Run through the Local Development guide to synth/diff locally and keep formatting tidy.
- If you changed
.projenrc.ts
, runnpx projen
so the generated workflows stay in sync with the new environment layout.
Advanced configuration
- Edit
environmentConfigs
in.projenrc.ts
to change deployment order, AWS accounts, or to opt environments in/out of branch deploys. - Need additional stages (for example,
staging
)? Add them to the array, rerunnpx projen
, and newcdk-deploy-<env>
workflows will appear automatically. - To adjust step logic or concurrency, modify
createCdkDeploymentWorkflows
and rerun Projen.
Ready to experiment with feature branches? Continue with Branch-based Development.