Very recently a discussion came up regarding the usage of different buildspec.yaml files, one for branch builds and the other for deployment builds and I was wondering, since after some research I wasn't able to find the best practices on this topic from AWS, what is the approach I should follow when it comes to this topic.
To give some context, each time a branch is created and code is pushed to it that triggers a branch build to run on AWS that will trigger an entire Maven cycle of running tests, plugins, building the code, etc... and some additional steps that are specified in the buildspec. On the other hand, when merging a branch into master or when pushing something to master directly, the process that was just mentioned for branch will also happen with the addition of deploying the code to production as well.
With all of this in mind, I wanted to ask the community if having all the instructions for both the production and branch execution in the same buildspec file is the best practice or if having different buildspecs would be the correct approach.
Additionally, one dev ops person I know said that it depends on the use case so both are correct depending on the particular use case but I wanted to confirm this with some documentation or second opinion as well.
Thank you everyone in advance and sorry if this question is not appropriate or badly formulated.