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 aWave
object that is actually aGitHubWave
object, but due to JSII rules the return type ofaddWave()
cannot be changed. If you need to usewave.addStageWithGitHubOptions()
then you should callpipeline.addGitHubWave()
instead, or you can useGitHubStage
s to carry the GitHub properties.
Example usage in TypeScript:
// 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@v4',
},
{
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@v4',
},
{
name: 'post wave action',
uses: '[email protected]',
with: {
'app-id': 4321,
'secrets': 'secrets',
},
},
],
}),
]);