Having a common cloud build file for different types of trigger in Google Cloud Build

I am trying to build a common YAML file for both push and tag-based triggers. I can build two YAML files and pass them to the triggers setting page in Google cloud build, but I want to have a common file for both of them.

In the push trigger, the YAML consists of unit testing and in the tag-based trigger, the YAML consists of unit testing and containerizing the application to be pushed to the artifact registry. As YAML is a text-formatting language and if/else conditions cannot be incorporated in it, how can I do this in one single file?

If you want any other information, please let me know and looking forward to helping, thanks in advance

You are right about cloudbuild.yaml describing a series of steps, without the option to use if-then decision. One can specify alternative entry points, but I don’t think this covers your requirements. You may refer to the “Can I have multiple sets of “steps:” in a cloudbuild.yaml” thread for related information.