aws-cdk icon indicating copy to clipboard operation
aws-cdk copied to clipboard

aws_codebuild: REPOSITORY_NAME/WORKFLOW_NAME webhook filters and webhook scope configuration

Open colyoonamaz opened this issue 1 year ago • 5 comments

Describe the feature

CodeBuild webhooks in CDK should support the REPOSITORY_NAME/WORKFLOW name filters e.g.

const source = codebuild.Source.gitHub({
      owner: 'owner',
      repo: 'repo',
      webhook: true,
      webhookFilters: [FilterGroup.inEventOf(EventAction.WORKFLOW_JOB_QUEUED).andRepositoryNameIs("repo_name")],
    })

as these filter types are currently missing (https://docs.aws.amazon.com/codebuild/latest/APIReference/API_WebhookFilter.html). Additionally, there is no option to provide a scope configuration for the webhook in the source (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codebuild-project-scopeconfiguration.html).

Use Case

The REPOSITORY_NAME/WORKFLOW_NAME filters are used to filter out organization/global webhook events, so that the webhook doesn't trigger builds for specific repositories/workflows. Additionally, scope configuration is needed to create an organization or global webhook (https://docs.aws.amazon.com/codebuild/latest/userguide/github-global-organization-webhook.html)

Proposed Solution

Add repository name and workflow name to the list of webhook filters and allow a scope configuration to be provided in the source for the webhook

Other Information

No response

Acknowledgements

  • [X] I may be able to implement this feature request
  • [X] This feature might incur a breaking change

CDK version used

2.162.1

Environment details (OS name and version, etc.)

Any

colyoonamaz avatar Oct 11 '24 23:10 colyoonamaz

Hi @colyoonamaz , thanks for reaching out.

Is this FR in accordance with this bug reported - https://github.com/aws/aws-cdk/issues/31726

Could you please check and share your insights ?

khushail avatar Oct 11 '24 23:10 khushail

I've submitted a PR that adds support for creating GitHub organization-level webhooks directly in the GitHubSource construct for CodeBuild.

However, I'm currently running into issues with building the aws-cdk-lib package locally and could use some help testing this feature. If anyone can assist by setting up a CodeBuild project with the new organization webhook property and verifying that it works as expected, I would greatly appreciate it!

Thanks in advance for any help and feedback!

dviryamin avatar Oct 12 '24 18:10 dviryamin

Thanks @dviryamin for submtting a PR. For guidance/help, you could-

  1. Reach out to CDK.DEV community and ask for help.
  2. Youtube tutorials.
  3. Community posts.

Hope this would be helpful!

khushail avatar Oct 14 '24 17:10 khushail

@khushail, https://github.com/aws/aws-cdk/issues/31726 looks like a separate issue, as this is in relation to missing attributes rather than webhook creation failures

colyoonamaz avatar Oct 14 '24 21:10 colyoonamaz

Hi @colyoonamaz, Thank you so much for your guidance and help! I was able to successfully build the aws-cdk-lib package locally and test my pull request with the new organization webhook feature. Everything worked as expected on my end.

It would be great if you could test it out as well and let me know if it resolves the issue you were facing. I’d really appreciate your feedback!

dviryamin avatar Oct 19 '24 19:10 dviryamin

I've submitted a PR that adds support for creating GitHub organization-level webhooks directly in the GitHubSource construct for CodeBuild.

However, I'm currently running into issues with building the aws-cdk-lib package locally and could use some help testing this feature. If anyone can assist by setting up a CodeBuild project with the new organization webhook property and verifying that it works as expected, I would greatly appreciate it!

Thanks in advance for any help and feedback!

@dviryamin could you post a snippet on how to currently get this done configuring the underlying codebuild CfnProject, until your PR is reviewed and merged?

shivatalwar avatar Oct 21 '24 00:10 shivatalwar

@shivatalwar I just posted a Gist Post with detailed tutorial

dviryamin avatar Oct 21 '24 17:10 dviryamin

Comments on closed issues and PRs are hard for our team to see. If you need help, please open a new issue that references this one.

github-actions[bot] avatar Oct 21 '24 23:10 github-actions[bot]

Thanks, marked the issue as completed

colyoonamaz avatar Oct 21 '24 23:10 colyoonamaz