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

aws_codebuild: REPOSITORY_NAME/WORKFLOW_NAME webhook filters and webhook scope configuration #31736

Closed
2 tasks done
colyoonamaz opened this issue Oct 11, 2024 · 9 comments · Fixed by #31740
Closed
2 tasks done
Labels
@aws-cdk/aws-codebuild Related to AWS CodeBuild effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2

Comments

@colyoonamaz
Copy link

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

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

CDK version used

2.162.1

Environment details (OS name and version, etc.)

Any

@colyoonamaz colyoonamaz added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Oct 11, 2024
@github-actions github-actions bot added the @aws-cdk/aws-codebuild Related to AWS CodeBuild label Oct 11, 2024
@khushail
Copy link
Contributor

Hi @colyoonamaz , thanks for reaching out.

Is this FR in accordance with this bug reported - #31726

Could you please check and share your insights ?

@khushail khushail added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. p2 and removed needs-triage This issue or PR still needs to be triaged. labels Oct 11, 2024
@khushail khushail self-assigned this Oct 11, 2024
@khushail khushail added the effort/medium Medium work item – several days of effort label Oct 12, 2024
@dviryamin
Copy link
Contributor

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!

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Oct 12, 2024
@khushail
Copy link
Contributor

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 khushail removed their assignment Oct 14, 2024
@colyoonamaz
Copy link
Author

@khushail, #31726 looks like a separate issue, as this is in relation to missing attributes rather than webhook creation failures

@dviryamin
Copy link
Contributor

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!

@shivatalwar
Copy link

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?

@dviryamin
Copy link
Contributor

@shivatalwar I just posted a Gist Post with detailed tutorial

Copy link

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.

@colyoonamaz
Copy link
Author

Thanks, marked the issue as completed

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 21, 2024
mergify bot pushed a commit that referenced this issue Oct 28, 2024
…#31740)

### Issue # (if applicable)
closes #31736

### Reason for this change
Currently, the AWS CDK `aws-codebuild` module lacks native support for creating GitHub organization-level webhooks through the `Source` construct. Users need to manually use the `CfnProject` to enable organization webhooks, which adds complexity and inconsistency to the CodeBuild setup. This PR introduces support for creating GitHub organization webhooks directly within the `Source` construct, streamlining the experience and making it more consistent with the rest of the AWS CDK's high-level constructs.

### Description of changes

- Enhanced the `GitHubSource` construct in the `aws-codebuild` module to support GitHub organization webhooks.
- Updated the `GitHubSource` construct's configuration to so when repo is not specified an organization webhook is created.
- Added filter of `REPOSITORY_NAME` to FilterGroups.

### Description of how you validated changes
- [x] Added unit tests to validate that organization-level webhooks are created correctly when repo is not specified.
- [x] Ran integration tests to ensure that the changes do not break any existing functionality related to project webhooks.
- [x] Tested deployment of a CodeBuild project with organization webhook setup in a sample CDK application to verify end-to-end functionality.

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
@aws-cdk/aws-codebuild Related to AWS CodeBuild effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants