Skip to content

Commit 1d93094

Browse files
authored
1 parent 665396f commit 1d93094

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

packages/aws-cdk-lib/aws-codebuild/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ const gitHubSource = codebuild.Source.gitHub({
6969
.inEventOf(codebuild.EventAction.PUSH)
7070
.andBranchIs('main')
7171
.andCommitMessageIs('the commit message'),
72+
codebuild.FilterGroup
73+
.inEventOf(codebuild.EventAction.RELEASED)
74+
.andBranchIs('main')
7275
], // optional, by default all pushes and Pull Requests will trigger a build
7376
});
7477
```

packages/aws-cdk-lib/aws-codebuild/lib/source.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,11 @@ export enum EventAction {
178178
*/
179179
PULL_REQUEST_UPDATED = 'PULL_REQUEST_UPDATED',
180180

181+
/**
182+
* Closing a Pull Request.
183+
*/
184+
PULL_REQUEST_CLOSED = 'PULL_REQUEST_CLOSED',
185+
181186
/**
182187
* Merging a Pull Request.
183188
*/
@@ -188,6 +193,24 @@ export enum EventAction {
188193
* Note that this event is only supported for GitHub and GitHubEnterprise sources.
189194
*/
190195
PULL_REQUEST_REOPENED = 'PULL_REQUEST_REOPENED',
196+
197+
/**
198+
* A release is created in the repository.
199+
* Works with GitHub only.
200+
*/
201+
RELEASED = 'RELEASED',
202+
203+
/**
204+
* A prerelease is created in the repository.
205+
* Works with GitHub only.
206+
*/
207+
PRERELEASED = 'PRERELEASED',
208+
209+
/**
210+
* A workflow job is queued in the repository.
211+
* Works with GitHub only.
212+
*/
213+
WORKFLOW_JOB_QUEUED = 'WORKFLOW_JOB_QUEUED',
191214
}
192215

193216
enum WebhookFilterTypes {

packages/aws-cdk-lib/aws-codebuild/test/codebuild.test.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,10 @@ describe('default properties', () => {
567567
webhookFilters: [
568568
codebuild.FilterGroup.inEventOf(codebuild.EventAction.PUSH).andTagIsNot('stable'),
569569
codebuild.FilterGroup.inEventOf(codebuild.EventAction.PULL_REQUEST_REOPENED).andBaseBranchIs('main'),
570+
codebuild.FilterGroup.inEventOf(codebuild.EventAction.RELEASED).andBaseBranchIs('main'),
571+
codebuild.FilterGroup.inEventOf(codebuild.EventAction.PRERELEASED).andBaseBranchIs('main'),
572+
codebuild.FilterGroup.inEventOf(codebuild.EventAction.WORKFLOW_JOB_QUEUED).andBaseBranchIs('main'),
573+
codebuild.FilterGroup.inEventOf(codebuild.EventAction.PULL_REQUEST_CLOSED).andBaseBranchIs('main'),
570574
],
571575
}),
572576
});
@@ -595,6 +599,22 @@ describe('default properties', () => {
595599
{ Type: 'EVENT', Pattern: 'PULL_REQUEST_REOPENED' },
596600
{ Type: 'BASE_REF', Pattern: 'refs/heads/main' },
597601
],
602+
[
603+
{ Type: 'EVENT', Pattern: 'RELEASED' },
604+
{ Type: 'BASE_REF', Pattern: 'refs/heads/main' },
605+
],
606+
[
607+
{ Type: 'EVENT', Pattern: 'PRERELEASED' },
608+
{ Type: 'BASE_REF', Pattern: 'refs/heads/main' },
609+
],
610+
[
611+
{ Type: 'EVENT', Pattern: 'WORKFLOW_JOB_QUEUED' },
612+
{ Type: 'BASE_REF', Pattern: 'refs/heads/main' },
613+
],
614+
[
615+
{ Type: 'EVENT', Pattern: 'PULL_REQUEST_CLOSED' },
616+
{ Type: 'BASE_REF', Pattern: 'refs/heads/main' },
617+
],
598618
],
599619
},
600620
});
@@ -664,6 +684,7 @@ describe('default properties', () => {
664684
codebuild.EventAction.PULL_REQUEST_CREATED,
665685
codebuild.EventAction.PULL_REQUEST_UPDATED,
666686
codebuild.EventAction.PULL_REQUEST_MERGED,
687+
codebuild.EventAction.PULL_REQUEST_CLOSED,
667688
).andTagIs('v.*'),
668689
// duplicate event actions are fine
669690
codebuild.FilterGroup.inEventOf(codebuild.EventAction.PUSH, codebuild.EventAction.PUSH).andActorAccountIsNot('aws-cdk-dev'),
@@ -685,7 +706,7 @@ describe('default properties', () => {
685706
Webhook: true,
686707
FilterGroups: [
687708
[
688-
{ Type: 'EVENT', Pattern: 'PULL_REQUEST_CREATED, PULL_REQUEST_UPDATED, PULL_REQUEST_MERGED' },
709+
{ Type: 'EVENT', Pattern: 'PULL_REQUEST_CREATED, PULL_REQUEST_UPDATED, PULL_REQUEST_MERGED, PULL_REQUEST_CLOSED' },
689710
{ Type: 'HEAD_REF', Pattern: 'refs/tags/v.*' },
690711
],
691712
[

0 commit comments

Comments
 (0)