Skip to content

Commit

Permalink
feat: add deployArgs and --require-approval=never default (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
diranged authored Oct 17, 2023
1 parent e8f0924 commit 0dfb2dc
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 18 deletions.
30 changes: 30 additions & 0 deletions API.md

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

19 changes: 18 additions & 1 deletion src/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,19 @@ export interface GitHubWorkflowProps extends PipelineBaseProps {
*/
readonly postBuildSteps?: github.JobStep[];

/**
* What approval level is required for deployments? By default this is
* `never` to ensure that all automated deployments succeed.
*
* @default "never"
*/
readonly requireApproval?: 'never' | 'any-change' | 'broadening';

/**
* Optional deploy aguments appended to the `cdk deploy ...` command.
*/
readonly deployArgs?: string[];

/**
* Whether or not to run a "diff" job first. Adds some time to the deploy
* process, but useful for understanding what changes are being applied.
Expand Down Expand Up @@ -147,6 +160,7 @@ export class GitHubWorkflow extends PipelineBase {
private readonly buildRunner: github.Runner;
private readonly preBuildSteps: github.JobStep[];
private readonly postBuildSteps: github.JobStep[];
private readonly deployArgs: string[];
private readonly diffFirst: boolean;
private readonly jobOutputs: Record<string, github.JobStepOutput[]> = {};
private readonly runner: github.Runner;
Expand All @@ -173,6 +187,7 @@ export class GitHubWorkflow extends PipelineBase {
this.postBuildSteps = props.postBuildSteps ?? [];
this.jobSettings = props.jobSettings;
this.diffFirst = props.diffFirst ?? false;
this.deployArgs = props.deployArgs ?? [];
this.workflowPath = props.workflowPath ?? '.github/workflows/deploy.yml';

if (!this.workflowPath.endsWith('.yml') && !this.workflowPath.endsWith('.yaml')) {
Expand All @@ -197,6 +212,8 @@ export class GitHubWorkflow extends PipelineBase {

this.runner = props.runner ?? github.Runner.UBUNTU_LATEST;
this.buildRunner = props.buildRunner ?? this.runner;

this.deployArgs.push(`--require-approval=${props.requireApproval ?? 'never'}`);
}

/**
Expand Down Expand Up @@ -667,7 +684,7 @@ export class GitHubWorkflow extends PipelineBase {
}
steps.push({
id: 'Deploy',
run: `npx cdk --app ${this.cdkoutDir} deploy ${stack.constructPath}`,
run: `npx cdk --app ${this.cdkoutDir} deploy ${stack.constructPath} ${this.deployArgs.join(' ')}`,
});

return steps;
Expand Down
16 changes: 10 additions & 6 deletions test/__snapshots__/github.test.ts.snap

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

1 change: 1 addition & 0 deletions test/__snapshots__/runner-provided.test.ts.snap

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

23 changes: 12 additions & 11 deletions test/__snapshots__/stage-options.test.ts.snap

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

1 change: 1 addition & 0 deletions test/github.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ test('pipeline with only a synth step', () => {
installCommands: ['yarn'],
commands: ['yarn build'],
}),
deployArgs: ['--arg1', '--arg2=foo'],
});

app.synth();
Expand Down

0 comments on commit 0dfb2dc

Please sign in to comment.