Skip to content

Commit

Permalink
ci(workflow): Update Node.js version to 20.18.1 across workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
dannysteenman committed Jan 14, 2025
1 parent c859870 commit 622bbd1
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cdk-deploy-production.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .github/workflows/cdk-deploy-test-branch.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .github/workflows/cdk-deploy-test.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .github/workflows/cdk-destroy-test-branch.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .github/workflows/release.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 6 additions & 14 deletions .projenrc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { DependabotScheduleInterval } from 'projen/lib/github';
import { NodePackageManager } from 'projen/lib/javascript';
import { YamlFile } from 'projen/lib/yaml';
import { createCdkDeploymentWorkflows } from './src/bin/cicd-helper';
import { addCdkActionTask } from './src/bin/env-helper';
import { Environment, EnvironmentConfig, addCdkActionTask } from './src/bin/env-helper';

// Set the minimum node version for AWS CDK and the GitHub actions workflow
const nodeVersion = '20.0.0';
const nodeVersion = '20.18.1';

/* Define the AWS region for the CDK app and github workflows
Default to us-east-1 if AWS_REGION is not set in your environment variables */
Expand Down Expand Up @@ -109,15 +109,8 @@ if (autoApproveWorkflow && autoApproveWorkflow instanceof YamlFile) {
autoApproveWorkflow.addOverride('jobs.approve.steps.0.uses', 'hmarr/auto-approve-action@v4');
}

// Define the target AWS accounts for the different environments
type Environment = 'test' | 'production';

interface EnvironmentConfig {
accountId: string;
enableBranchDeploy: boolean;
}

const environmentConfigs: Record<Environment, EnvironmentConfig> = {
// Configure the environments and their corresponding AWS account IDs
const environmentConfigs: Partial<Record<Environment, EnvironmentConfig>> = {
test: { accountId: '987654321012', enableBranchDeploy: true },
production: { accountId: '123456789012', enableBranchDeploy: false },
};
Expand All @@ -126,8 +119,7 @@ const environmentConfigs: Record<Environment, EnvironmentConfig> = {
The environment variables are passed to the CDK CLI to deploy to the correct account and region
The `cdkDeploymentTask` function is defined in the `src/bin/helper.ts` file
You can now run a command like: `npm run dev:synth` to synthesize your aws cdk dev stacks */
const github = project.github;
if (github) {
if (project.github) {
for (const [env, config] of Object.entries(environmentConfigs) as [Environment, EnvironmentConfig][]) {
// Adds customized 'npm run' commands for executing cdk synth, test, deploy and diff for each environment
addCdkActionTask(project, {
Expand All @@ -150,7 +142,7 @@ if (github) {

// Adds GitHub action workflows for deploying the CDK stacks to the target AWS account
createCdkDeploymentWorkflows(
github,
project.github,
config.accountId,
awsRegion,
env,
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions src/bin/env-helper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import type { awscdk } from 'projen';

/** Represents the possible deployment environments. */
export type Environment = 'sandbox' | 'development' | 'test' | 'staging' | 'production';

/** Configuration settings for a specific environment. */
export interface EnvironmentConfig {
/** The unique identifier for the account. */
accountId: string;
/** Flag to enable or disable branch deployments. */
enableBranchDeploy: boolean;
}

/**
* Adds customized 'npm run' commands for executing AWS CDK actions (synth, diff, deploy, destroy)
* for a specific environment and branch (if applicable).
Expand Down

0 comments on commit 622bbd1

Please sign in to comment.