@jjrawlins/cdk-deploy-pr-github-action
A projen construct that generates GitHub Actions workflows for AWS CDK deployments.
Features
- Automated deploy pipeline (
deploy.yml) — synth, publish assets, and deploy on push to main - Manual dispatch workflow (
deploy-dispatch.yml) — deploy any previously published version to any environment - Versioned cloud assemblies — publishes
cdk.outto GitHub Packages with auto-incrementing versions - GitHub Releases — each deploy creates a git tag and GitHub Release tied to the assembly version
- Multi-stage deployments — parallel or sequential stages with
dependsOnordering - GitHub Environments — per-stage environment protection rules, secrets scoping, and deployment approvals
- Manual approval stages — exclude stages from auto-deploy, only deployable via dispatch
- Per-stage IAM role overrides — cross-account deployments with per-stage OIDC roles
- Concurrency groups — prevents concurrent deployments to the same stage
- Rollback support — redeploy any previous assembly version via the dispatch workflow
Installation
npm install @jjrawlins/cdk-deploy-pr-github-action
Also available on PyPI, NuGet, and Go.
Usage
In your .projenrc.ts:
import { CdkDeployPipeline } from '@jjrawlins/cdk-deploy-pr-github-action';
new CdkDeployPipeline(project, {
stackPrefix: 'MyApp',
pkgNamespace: '@my-org',
iamRoleArn: 'arn:aws:iam::111111111111:role/GitHubActionsOidcRole',
iamRoleRegion: 'us-east-1',
stages: [
{
name: 'dev',
env: { account: '222222222222', region: 'us-east-1' },
environment: 'development',
},
{
name: 'staging',
env: { account: '333333333333', region: 'us-east-1' },
environment: 'staging',
dependsOn: ['dev'],
},
{
name: 'prod',
env: { account: '444444444444', region: 'us-east-1' },
environment: 'production',
dependsOn: ['staging'],
manualApproval: true, // Only deployable via dispatch
},
],
});
Run npx projen to generate the workflow files.
Generated Workflows
deploy.yml
Triggered on push to main. Jobs:
- synth — checks out code, installs dependencies, runs
cdk synth, uploads cloud assembly artifact - publish-assets — publishes Lambda/container assets to AWS, versions and publishes the cloud assembly to GitHub Packages, creates a git tag and GitHub Release
- deploy-{stage} — one job per non-manual stage, deploys stacks using the cloud assembly artifact
deploy-dispatch.yml
Triggered manually via workflow_dispatch. Inputs:
- environment — target environment (dropdown of configured stages)
- version — assembly version to deploy (e.g.,
0.0.4)
Downloads the specified assembly version from GitHub Packages and deploys it. This enables:
- Deploying to
manualApprovalstages (e.g., production) - Rolling back to any previous version
- Ad-hoc deployments outside the normal CI/CD flow
Options
CdkDeployPipelineOptions
| Option | Type | Default | Description |
|---|---|---|---|
pkgNamespace |
string |
required | npm scope for assembly packages (e.g., @my-org) |
stackPrefix |
string |
required | Stack name prefix (e.g., MyApp -> MyApp-dev) |
iamRoleArn |
string |
required | Default OIDC role ARN for AWS credential assumption |
stages |
DeployStageOptions[] |
required | Deployment stages |
iamRoleRegion |
string |
us-east-1 |
Default AWS region for OIDC credential assumption |
nodeVersion |
string |
24.x |
Node.js version for workflow runners |
cdkCommand |
string |
npx cdk |
CDK CLI command prefix |
installCommand |
string |
yarn install --check-files --frozen-lockfile |
Package install command |
manualDeployment |
boolean |
true |
Generate the dispatch workflow |
useGithubPackagesForAssembly |
boolean |
true |
Publish cloud assembly to GitHub Packages |
branchName |
string |
main |
Branch that triggers deployments |
workingDirectory |
string |
— | Subdirectory where the CDK app lives (e.g., infra). Sets defaults.run.working-directory on all jobs and adjusts artifact paths. |
preGitHubSteps |
any |
— | Steps to run before deploy (after install/download, before AWS creds). Static array or factory ({ stage, workingDirectory }) => steps[]. Applied to deploy jobs only. |
postGitHubSteps |
any |
— | Steps to run after deploy. Static array or factory ({ stage, workingDirectory }) => steps[]. Applied to deploy jobs only. |
DeployStageOptions
| Option | Type | Default | Description |
|---|---|---|---|
name |
string |
required | Stage name (used in job IDs and stack names) |
env |
{ account, region } |
required | AWS target environment |
environment |
string |
stage name | GitHub Environment name |
iamRoleArn |
string |
pipeline default | Override OIDC role for this stage |
iamRoleRegion |
string |
pipeline default | Override AWS region for this stage |
dependsOn |
string[] |
[] |
Stages that must complete first |
stacks |
string[] |
['{stackPrefix}-{name}'] |
CDK stack names to deploy |
manualApproval |
boolean |
false |
Exclude from auto-deploy, dispatch only |
Examples
Parallel stages
Stages without dependsOn run in parallel after asset publishing:
stages: [
{ name: 'us-east-1', env: usEast1Env },
{ name: 'eu-west-1', env: euWest1Env },
]
Cross-account with per-stage roles
stages: [
{
name: 'dev',
env: { account: '222222222222', region: 'us-east-1' },
iamRoleArn: 'arn:aws:iam::222222222222:role/DevDeployRole',
},
{
name: 'prod',
env: { account: '333333333333', region: 'us-east-1' },
iamRoleArn: 'arn:aws:iam::333333333333:role/ProdDeployRole',
manualApproval: true,
},
]
Rolling back
Each deploy creates a GitHub Release with the assembly version. To roll back:
gh workflow run deploy-dispatch.yml -f environment=production -f version=0.0.3
Monorepo support
If your CDK app lives in a subdirectory, use the workingDirectory option:
new CdkDeployPipeline(project, {
stackPrefix: 'MyApp',
pkgNamespace: '@my-org',
iamRoleArn: 'arn:aws:iam::111111111111:role/GitHubActionsOidcRole',
workingDirectory: 'infra',
stages: [
{ name: 'dev', env: devEnv, environment: 'development' },
{ name: 'prod', env: prodEnv, environment: 'production', manualApproval: true },
],
});
This sets defaults.run.working-directory: infra on all workflow jobs and adjusts artifact upload/download paths to infra/cdk.out/.
Pre/post workflow steps
Use preGitHubSteps and postGitHubSteps to run custom steps before and after deployments. These are applied to deploy jobs only (not synth or publish-assets). Useful for building source code, sending Slack notifications, or running health checks.
new CdkDeployPipeline(project, {
stackPrefix: 'MyApp',
pkgNamespace: '@my-org',
iamRoleArn: 'arn:aws:iam::111111111111:role/GitHubActionsOidcRole',
workingDirectory: 'infra',
stages: [
{ name: 'dev', env: devEnv, environment: 'development' },
],
preGitHubSteps: ({ stage, workingDirectory }) => [
// Build at project root (overrides working-directory default)
{ name: 'Build app', run: 'npm run build', 'working-directory': '.' },
],
postGitHubSteps: ({ stage }) => [
{ name: 'Notify Slack', uses: 'slackapi/slack-github-action@v2', with: { /* ... */ } },
],
});
Pre/post steps are also passed through to deploy-dispatch.yml so dispatch deployments get the same hooks.
Deploy jobs include step IDs creds (AWS Credentials) and deploy (Deploy step) that post-steps can reference via ${{ steps.deploy.outcome }}.
Note: When
workingDirectoryis set, allrun:steps inherit that directory by default. To run a step at the repository root, addworking-directory: '.'to that step.
Prerequisites
- AWS OIDC identity provider configured for GitHub Actions
- IAM role with trust policy for GitHub Actions OIDC
- GitHub Environments configured for deployment protection rules (optional)
License
Apache-2.0
Metadata
Release files for jjrawlins-cdk-deploy-pr-github-action 0.0.38
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| jjrawlins_cdk_deploy_pr_github_action-0.0.38.tar.gz | 72.0 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| jjrawlins_cdk_deploy_pr_github_action-0.0.38-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 141.7 kB
Release files / jjrawlins_cdk_deploy_pr_github_action-0.0.38.tar.gz
| Download URL | jjrawlins_cdk_deploy_pr_github_action-0.0.38.tar.gz |
|---|---|
| Size | 72.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d7a89eb2f7dcc4cd9ca3b7f3b67ecd57ba91ee8da4c69d09a3cd2de1fc84a6f5
|
|
BLAKE2b-256 checksum How to use checksums |
07ed3a636b3a07c7c5722fad610191dbc032b6bb81a6a919347e39f23e62d91b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.14.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.
Transparency logRelease files / jjrawlins_cdk_deploy_pr_github_action-0.0.38-py3-none-any.whl
| Download URL | jjrawlins_cdk_deploy_pr_github_action-0.0.38-py3-none-any.whl |
|---|---|
| Size | 69.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f80d2d5a11bbc5f464137df992e7b41047b35d998b8b41a07e45621e5ad41af4
|
|
BLAKE2b-256 checksum How to use checksums |
2ead55f980b0da32a249a78e100bec70af08e818ff536a77f6fe431d77b3b8ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.14.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.
Transparency logSecurity for jjrawlins-cdk-deploy-pr-github-action 0.0.38
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for jjrawlins_cdk_deploy_pr_github_action-0.0.38.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.