Skip to content

Commit 91ef750

Browse files
committed
feat: add CDK diff PR workflow and update workflow actions to v5
1 parent c713e9b commit 91ef750

File tree

12 files changed

+165
-6
lines changed

12 files changed

+165
-6
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/cdk-deploy-production.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/cdk-deploy-test-branch.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/cdk-deploy-test.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/cdk-destroy-test-branch.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/cdk-diff-pr.yml

Lines changed: 44 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.gitignore

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.projen/files.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.projenrc.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { awscdk, JsonFile, TextFile } from 'projen';
22
import { DependabotScheduleInterval } from 'projen/lib/github';
33
import { NodePackageManager } from 'projen/lib/javascript';
44
import { IndentStyle, QuoteStyle, Semicolons, TrailingCommas } from 'projen/lib/javascript/biome/biome-config';
5-
import { createCdkDeploymentWorkflows } from './src/bin/cicd-helper';
5+
import { createCdkDeploymentWorkflows, createCdkDiffPrWorkflow } from './src/bin/cicd-helper';
66
import { addCdkActionTask, type Environment, type EnvironmentConfig } from './src/bin/env-helper';
77

88
// Set the minimum node version for AWS CDK and the GitHub actions workflow
@@ -195,6 +195,16 @@ if (project.github) {
195195
orderedEnvironments,
196196
);
197197
}
198+
199+
// Create CDK diff PR workflow (once, using the highest environment)
200+
createCdkDiffPrWorkflow(
201+
project.github,
202+
environmentConfigs[environmentConfigs.length - 1].accountId, // Uses the account that should be deployed to last (usually production)
203+
awsRegion,
204+
githubRole,
205+
nodeVersion,
206+
orderedEnvironments,
207+
);
198208
}
199209

200210
project.synth();

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Welcome to the starting line of your next AWS CDK project. This repository is cr
6363
- 🧹 **Preconfigured TypeScript Excellence**: Hit the ground running with pre-set compiler options in [tsconfig.json](./tsconfig.json), ensuring your code is clean, efficient, and error-free from the start.
6464
- 📏 **Best Practice Linting & Formatting**: Adopt coding best practices effortlessly with a pre-configured Biome setup [biome.jsonc](./biome.jsonc), maintaining high code quality and consistency.
6565
- 💻 **Branch-based Deployments**: Deploy multiple CDK stacks to the same AWS environments based on the Git branch. This enables you to easily test changes when multiple developers work on the same code base.
66+
- 🔍 **Automated CDK Diff on PRs**: Automatically runs `cdk diff` on pull requests to the main branch and posts the infrastructure changes as a comment. This allows you to validate your infrastructure changes before merging. Powered by our custom-built [AWS CDK Diff PR Commenter](https://github.com/marketplace/actions/aws-cdk-diff-pr-commenter) GitHub Action.
6667
- 📦 **Automated Dependency Management**: Dependabot creates grouped PRs, with auto-approval for passing checks using `hmarr/auto-approve-action@v4`, streamlining updates while maintaining project stability.
6768

6869
## Setup Guide

0 commit comments

Comments
 (0)