2
votes

In my project, I have buildspec.yml that deploys my app and creates a new release on GitHub.
If I create a new CodeBuild project with the yml file above and watch master branch with GitHub push webhook, it keeps releasing new versions forever...

It seems that if I watch "push" event, the webhook also triggers a new build if new releases (or new tag creation?) is detected. And that release triggers another webhook "push" event, entering infinite release loop.

Is there any way to make the build only reactive to real pushes?

(or perhaps, is making new releases in buildspec.yml not a good practice...?)

2

2 Answers

1
votes

The push event does indeed detect tag and branch creation.

But its event payload also include "size": The number of commits in the push.

If that size is 0, your listener won't have to trigger any build.

1
votes

There is native support for filtering your webhook events in CodeBuild. Details in https://docs.aws.amazon.com/codebuild/latest/userguide/sample-github-pull-request.html#sample-github-pull-request-filter-webhook-events-console. You can set a filter to opt-out of builds, when it is triggered due to a release tag.