Although, of course, this works like intended it is a lot of “boilerplate” code. drone.yml becomes quite long with a lot of code duplication.
What would be the best practice to achieve this behavior?
Ideally, I would think of either chaining config files, like only defining the pipeline names and triggers in drone.yml and and the actual steps: inside foo.yml (since they are exactly the same for each build, they just differ in triggers and corresponding tags).
Or, alternatively, something in the direction of mapping triggers and tags to use:
instead of separate pipelines with duplicate steps, you could have a single pipeline and use the when clause to limit step execution. You could further explore yaml anchors, extensions and aliases to reduce boilerplate.
when you define anchors they need to be in the same document (in your above example, they are in separate yaml documents, separated by the ---). This is a limitation of the yaml specification, not Drone itself.