Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(codebuild): add missing types for webhook filters #30064

Merged
merged 4 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/aws-cdk-lib/aws-codebuild/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ const gitHubSource = codebuild.Source.gitHub({
.inEventOf(codebuild.EventAction.PUSH)
.andBranchIs('main')
.andCommitMessageIs('the commit message'),
codebuild.FilterGroup
.inEventOf(codebuild.EventAction.RELEASED)
.andBranchIs('main')
], // optional, by default all pushes and Pull Requests will trigger a build
});
```
Expand Down
23 changes: 23 additions & 0 deletions packages/aws-cdk-lib/aws-codebuild/lib/source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ export enum EventAction {
*/
PULL_REQUEST_UPDATED = 'PULL_REQUEST_UPDATED',

/**
* Closing a Pull Request.
*/
PULL_REQUEST_CLOSED = 'PULL_REQUEST_CLOSED',

/**
* Merging a Pull Request.
*/
Expand All @@ -188,6 +193,24 @@ export enum EventAction {
* Note that this event is only supported for GitHub and GitHubEnterprise sources.
*/
PULL_REQUEST_REOPENED = 'PULL_REQUEST_REOPENED',

/**
* A release is created in the repository.
* Works with GitHub only.
*/
RELEASED = 'RELEASED',

/**
* A prerelease is created in the repository.
* Works with GitHub only.
*/
PRERELEASED = 'PRERELEASED',

/**
* A workflow job is queued in the repository.
* Works with GitHub only.
*/
WORKFLOW_JOB_QUEUED = 'WORKFLOW_JOB_QUEUED',
}

enum WebhookFilterTypes {
Expand Down
23 changes: 22 additions & 1 deletion packages/aws-cdk-lib/aws-codebuild/test/codebuild.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,10 @@ describe('default properties', () => {
webhookFilters: [
codebuild.FilterGroup.inEventOf(codebuild.EventAction.PUSH).andTagIsNot('stable'),
codebuild.FilterGroup.inEventOf(codebuild.EventAction.PULL_REQUEST_REOPENED).andBaseBranchIs('main'),
codebuild.FilterGroup.inEventOf(codebuild.EventAction.RELEASED).andBaseBranchIs('main'),
msambol marked this conversation as resolved.
Show resolved Hide resolved
codebuild.FilterGroup.inEventOf(codebuild.EventAction.PRERELEASED).andBaseBranchIs('main'),
codebuild.FilterGroup.inEventOf(codebuild.EventAction.WORKFLOW_JOB_QUEUED).andBaseBranchIs('main'),
codebuild.FilterGroup.inEventOf(codebuild.EventAction.PULL_REQUEST_CLOSED).andBaseBranchIs('main'),
],
}),
});
Expand Down Expand Up @@ -595,6 +599,22 @@ describe('default properties', () => {
{ Type: 'EVENT', Pattern: 'PULL_REQUEST_REOPENED' },
{ Type: 'BASE_REF', Pattern: 'refs/heads/main' },
],
[
{ Type: 'EVENT', Pattern: 'RELEASED' },
{ Type: 'BASE_REF', Pattern: 'refs/heads/main' },
],
[
{ Type: 'EVENT', Pattern: 'PRERELEASED' },
{ Type: 'BASE_REF', Pattern: 'refs/heads/main' },
],
[
{ Type: 'EVENT', Pattern: 'WORKFLOW_JOB_QUEUED' },
{ Type: 'BASE_REF', Pattern: 'refs/heads/main' },
],
[
{ Type: 'EVENT', Pattern: 'PULL_REQUEST_CLOSED' },
{ Type: 'BASE_REF', Pattern: 'refs/heads/main' },
],
],
},
});
Expand Down Expand Up @@ -664,6 +684,7 @@ describe('default properties', () => {
codebuild.EventAction.PULL_REQUEST_CREATED,
codebuild.EventAction.PULL_REQUEST_UPDATED,
codebuild.EventAction.PULL_REQUEST_MERGED,
codebuild.EventAction.PULL_REQUEST_CLOSED,
).andTagIs('v.*'),
// duplicate event actions are fine
codebuild.FilterGroup.inEventOf(codebuild.EventAction.PUSH, codebuild.EventAction.PUSH).andActorAccountIsNot('aws-cdk-dev'),
Expand All @@ -685,7 +706,7 @@ describe('default properties', () => {
Webhook: true,
FilterGroups: [
[
{ Type: 'EVENT', Pattern: 'PULL_REQUEST_CREATED, PULL_REQUEST_UPDATED, PULL_REQUEST_MERGED' },
{ Type: 'EVENT', Pattern: 'PULL_REQUEST_CREATED, PULL_REQUEST_UPDATED, PULL_REQUEST_MERGED, PULL_REQUEST_CLOSED' },
{ Type: 'HEAD_REF', Pattern: 'refs/tags/v.*' },
],
[
Expand Down
Loading