forked from cdklabs/cdk-pipelines-github
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/NathanTCz/cdk-pipelines-github
- Loading branch information
Showing
17 changed files
with
6,185 additions
and
1,202 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
# Example of how to add a Wave to a pipeline | ||
|
||
You can add a Wave to a pipeline, where each stage of a wave will build in parallel. | ||
|
||
> **Note**: The `pipeline.addWave()` call will return a `Wave` object that is actually a `GitHubWave` object, but | ||
> due to JSII rules the return type of `addWave()` cannot be changed. If you need to use | ||
> `wave.addStageWithGitHubOptions()` then you should call `pipeline.addGitHubWave()` instead, or you can | ||
> use `GitHubStage`s to carry the GitHub properties. | ||
Example usage in TypeScript: | ||
|
||
```ts | ||
// make a new pipeline | ||
import { ShellStep } from 'aws-cdk-lib/pipelines'; | ||
|
||
const app = new App(); | ||
|
||
const pipeline = new GitHubWorkflow(app, 'Pipeline', { | ||
synth: new ShellStep('Build', { | ||
commands: [ | ||
'yarn install', | ||
'yarn build', | ||
], | ||
}), | ||
awsCreds: AwsCredentials.fromOpenIdConnect({ | ||
gitHubActionRoleArn: 'arn:aws:iam::<account-id>:role/GitHubActionRole', | ||
}), | ||
}); | ||
|
||
// make a stage | ||
const stageA = new GitHubStage(app, 'MyStageA', { | ||
env: { account: '111111111111', region: 'us-east-1' }, | ||
{ | ||
jobSettings: { | ||
if: "success() && contains(github.event.issue.labels.*.name, 'deployToA')", | ||
}, | ||
} | ||
}); | ||
// add a stack | ||
new Stack(stageA, 'MyStackA'); | ||
|
||
// make a second stage | ||
const stageB = new GitHubStage(app, 'MyStageB', { | ||
env: { account: '12345678901', region: 'us-east-1' }, | ||
jobSettings: { | ||
if: "success() && contains(github.event.issue.labels.*.name, 'deployToB')", | ||
}, | ||
}); | ||
// add a stack to that second stage | ||
new Stack(stageB, 'MyStackB'); | ||
|
||
// Make a wave to have the stages run in parallel (and not depend on each other) | ||
// We can also add steps to be run once before and once after ALL of the stages in this wave | ||
const wave = pipeline.addWave('MyWave', { | ||
pre: [ | ||
// add a pre-wave actions | ||
new GitHubActionStep('PreWaveAction', { | ||
jobSteps: [ | ||
{ | ||
name: 'pre wave action', | ||
uses: '[email protected]', | ||
with: { | ||
'app-id': 1234, | ||
'secrets': 'my-secrets', | ||
}, | ||
}, | ||
], | ||
}), | ||
], | ||
|
||
post: [ | ||
new GitHubActionStep('PostWaveAction', { | ||
jobSteps: [ | ||
{ | ||
name: 'Checkout', | ||
uses: 'actions/checkout@v3', | ||
}, | ||
{ | ||
name: 'post wave action', | ||
uses: '[email protected]', | ||
with: { | ||
'app-id': 4321, | ||
'secrets': 'secrets', | ||
}, | ||
}, | ||
], | ||
}), | ||
], | ||
}); | ||
|
||
// Now add both stages to the wave - they will build in parallel | ||
wave.addStage(stageA); | ||
wave.addStage(stageB); | ||
|
||
// pre- and post-wave actions can both be added after the wave is constructed | ||
// with wave.addPre() and wave.addPost() | ||
wave.addPost([ | ||
new GitHubActionStep('PostWaveAction', { | ||
jobSteps: [ | ||
{ | ||
name: 'Checkout', | ||
uses: 'actions/checkout@v3', | ||
}, | ||
{ | ||
name: 'post wave action', | ||
uses: '[email protected]', | ||
with: { | ||
'app-id': 4321, | ||
'secrets': 'secrets', | ||
}, | ||
}, | ||
], | ||
}), | ||
]); | ||
``` |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { AddStageOpts } from 'aws-cdk-lib/pipelines'; | ||
import { JobSettings } from './pipeline'; | ||
import { StackCapabilities } from './stage-options'; | ||
|
||
/** | ||
* Common properties to extend both StageProps and AddStageOpts | ||
*/ | ||
|
||
export interface GitHubCommonProps { | ||
/** | ||
* Run the stage in a specific GitHub Environment. If specified, | ||
* any protection rules configured for the environment must pass | ||
* before the job is set to a runner. For example, if the environment | ||
* has a manual approval rule configured, then the workflow will | ||
* wait for the approval before sending the job to the runner. | ||
* | ||
* Running a workflow that references an environment that does not | ||
* exist will create an environment with the referenced name. | ||
* @see https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment | ||
* | ||
* @default - no GitHub environment | ||
*/ | ||
readonly gitHubEnvironment?: string; | ||
|
||
/** | ||
* In some cases, you must explicitly acknowledge that your CloudFormation | ||
* stack template contains certain capabilities in order for CloudFormation | ||
* to create the stack. | ||
* | ||
* If insufficiently specified, CloudFormation returns an `InsufficientCapabilities` | ||
* error. | ||
* | ||
* @default ['CAPABILITY_IAM'] | ||
*/ | ||
readonly stackCapabilities?: StackCapabilities[]; | ||
|
||
/** | ||
* Job level settings that will be applied to all jobs in the stage. | ||
* Currently the only valid setting is 'if'. | ||
*/ | ||
readonly jobSettings?: JobSettings; | ||
} | ||
|
||
/** | ||
* Options to pass to `addStageWithGitHubOpts`. | ||
*/ | ||
export interface AddGitHubStageOptions extends AddStageOpts, GitHubCommonProps {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.